• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsp parameters pass more than one value to the handler

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joyce Hughes wrote:Can someone look at my code and tell me what the problem is?


That's way too much unformatted code to look at.

Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just guessing -- when a form is submitted, all inputs in the form are submitted.
reply
    Bookmark Topic Watch Topic
  • New Topic