Hi, I have a
jsp page that has three buttons that the user can click. The value is then passed to a javascript function where it sends it to a Request Handler. When I click on one, it still passes all three to the handler. Can someone look at my code and tell me what the problem is?
part of the code is below:
<%
final
String buttonAction_AllPatients = "ALL PATIENTS";
final String buttonAction_MyPatients = "MY PATIENTS";
final String buttonAction_MyClinics = "MY CLINICS";
%>
<html>
<head>
<title>My Patients Admitted or Discharged within the Last 72 hours</title>
<script type="text/javascript" src="../js/common.js"></script>
<link rel="stylesheet" href="../stylesheets/main.css" type="text/css">
<script LANGUAGE="javascript" type="text/javascript">
function submit_onclick(action)
{
//alert("action="+action);
// VALIDATE SELECTIONS...
var ok = "YES";
if(action == "<%=buttonAction_AllPatients%>")
{
alert("actionpt="+ action);
var varr = "";
varrr = document.SETUICFORM.KEY_PATIENTSA.value;
alert("varrr="+varr);
document.SETUICFORM.submit();
}
else if(action == "<%=buttonAction_MyPatients%>")
{
alert("actionpt="+ action);
var varr = "";
varr = document.SETUICFORM.KEY_PATIENTSB.value;
alert("varr="+varr);
document.SETUICFORM.submit();
}
else if(action == "<%=buttonAction_MyClinics%>")
{
alert("actionpt="+ action);
var varr = "";
varr = document.SETUICFORM.KEY_PATIENTSC.value;
alert("varr="+varr);
document.SETUICFORM.submit();
}
else
{
ok = "NO";
alert("No button was clicked")
}
}
</script>
</head>
<%@ include file = "../provider/navigate.inc" %>
<body topmargin="0" leftmargin="0" bgcolor="white">
<div id="contentBox">
<table border="0" id="tblBody2" >
<tr class="white" >
<td class="tblcell14" nowrap><strong>Portal Views> My Admitted/Discharged Pts (within the last 72 Hours)</strong></td>
<td class="tblcellp" nowrap>
Personal Data - Privacy Act of 1974 (PL 93-579)</td>
</tr>
<tr >
<td >
</td>
</tr>
<%
// Retrieve the Data...
HospStay_72_Data viewData = ( HospStay_72_Data ) request.getAttribute( HttpKeys.KEY_CON_DATA );
String errorText = viewData.getErrorText();
if ( errorText != null ) {
%>
<tr >
<td >
<table border="0" id="tblBody1" >
<tr class="yellow10">
<td class="tblcellb" >
<strong>Please report the following error using the Feedback icon:
Error: Portal Views->My Admitted/Discharged Patients: </strong>
Error = <%= errorText %>
</td>
</tr>
</table>
</td>
</tr>
<%
}
else {
%>
<%
url = mWebAppName + "/control/hospitalstaybyuic";
%>
<form name="SETUICFORM" method="POST" action="<%= url %>">
<tr >
<td>
For ALL patients Admitted/Discharged within 72 hours, click
<input type="button" class="button" value="ALL PATIENTS" onClick="javascript:submit_onclick('<%= buttonAction_AllPatients %>')">
<input type="hidden" name="KEY_PATIENTSA" value="<%= buttonAction_AllPatients %>">
</td>
</tr>
<tr >
<td>
For MY patients Admitted/Discharged within 72 hours, click
<input type="button" class="button" value="MY PATIENTS" onClick="javascript:submit_onclick('<%= buttonAction_MyPatients %>')">
<input type="hidden" name="KEY_PATIENTSB" value="<%= buttonAction_MyPatients %>">
</td>
</tr>
<tr >
<td>
For patients in MY CLINIC Admitted/Discharged within 72 hours, click
<input type="button" class="button" value="MY CLINICS" onClick="javascript:submit_onclick('<%= buttonAction_MyClinics %>')">
<input type="hidden" name="KEY_PATIENTSC" value="<%= buttonAction_MyClinics %>">
</td>
</tr>
</form>
<tr >
<td >
</td>
</tr>
The request handler then gets the values in this piece of code
String allPatients = request.getParameter("KEY_PATIENTSA");
String myPatients = request.getParameter("KEY_PATIENTSB");
String myClinics = request.getParameter("KEY_PATIENTSC");
Thank you for any help!