ramani081399
asked on
Passing selected values.
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<form NAME="ControlPanelForm" method=POST id=form1 name=form1 >
<table >
<tr>
<td>
<select name="ControlPanelOne">
<option selected>Choose Option</option>
<option value="Reverse.jsp">Revers e</option>
<option value="Correct.jsp">Correc t</option> <option>Do wnload</op tion><opti on>Print</ option>
</select>
</td>
</tr>
<tr>
<td>
<INPUT type="checkbox" id=checkbox1 name=checkbox1 value="item1">
</td>
<td>
04/14/02
</td>
<td >
<a href="#">421</a>
</td>
<td >
$123,456,789.00
</td>
<td >
$1500.00
</td>
<td >
$1000.00
</td>
</tr>
<tr>
<td>
<INPUT type="checkbox" id=checkbox2 name=checkbox2 value="item2">
</td>
<td >
03/09/02
</td>
<td >
<a href="#">422</a>
</td>
<td >
$103,456,789.00
</td>
<td >
$1500.00
</td>
<td >
$0
</td>
</tr>
<tr>
<td>
<input type="Submit" value="Submit" id=submit1 name=submit1>
</td>
</tr>
</table>
</form>
<P> </P>
</BODY>
</HTML>
I have a html form as shown above. When the user selects a check box and chosses a option from the drop down ie either reverse or correct,the user should be presented the reverse.jsp with one row of values which the user selects.If the user selects two checkboxes and chooses reverse from the drop down then he should see two rows of data of the selected ones in Reverse.jsp.
I would like to know as to how to do it. Also in the jsp page i would like to include a javascript that highlights the selected rows.A code for doing this would be appreciated.
Thanks
Ramani
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<form NAME="ControlPanelForm" method=POST id=form1 name=form1 >
<table >
<tr>
<td>
<select name="ControlPanelOne">
<option selected>Choose Option</option>
<option value="Reverse.jsp">Revers
<option value="Correct.jsp">Correc
</select>
</td>
</tr>
<tr>
<td>
<INPUT type="checkbox" id=checkbox1 name=checkbox1 value="item1">
</td>
<td>
04/14/02
</td>
<td >
<a href="#">421</a>
</td>
<td >
$123,456,789.00
</td>
<td >
$1500.00
</td>
<td >
$1000.00
</td>
</tr>
<tr>
<td>
<INPUT type="checkbox" id=checkbox2 name=checkbox2 value="item2">
</td>
<td >
03/09/02
</td>
<td >
<a href="#">422</a>
</td>
<td >
$103,456,789.00
</td>
<td >
$1500.00
</td>
<td >
$0
</td>
</tr>
<tr>
<td>
<input type="Submit" value="Submit" id=submit1 name=submit1>
</td>
</tr>
</table>
</form>
<P> </P>
</BODY>
</HTML>
I have a html form as shown above. When the user selects a check box and chosses a option from the drop down ie either reverse or correct,the user should be presented the reverse.jsp with one row of values which the user selects.If the user selects two checkboxes and chooses reverse from the drop down then he should see two rows of data of the selected ones in Reverse.jsp.
I would like to know as to how to do it. Also in the jsp page i would like to include a javascript that highlights the selected rows.A code for doing this would be appreciated.
Thanks
Ramani
ASKER
ryancys,
Could post a code snippet as to how to do this.
Ramani
Let me check it tonight :) cheers
you select reverse from the form it will take to reverse.jsp
========================== ========== ========== ========== ===
<HTML>
<HEAD>
<TITLE></TITLE>
<script>
function jump()
{
var index=document.form1.Contr olPanelOne .options.s electedInd ex;
var temp=document.form1.Contro lPanelOne. options[in dex].value ;
alert(temp);
document.form1.action=temp ;
document.form1.submit();
}
</script>
</HEAD>
<BODY>
<form NAME="ControlPanelForm" method=POST id=form1 name=form1 >
<table >
<tr>
<td>
<select name="ControlPanelOne" onchange=jump();>
<option selected>Choose Option</option>
<option value="Reverse.jsp">Revers e</option>
<option value="Correct.jsp">Correc t</option> <option>Do wnload</op tion><opti on>Print</ option>
</select>
</td>
</tr>
<tr>
<td>
<INPUT type="checkbox" id=checkbox1 name=checkbox1 value="item1">
</td>
<td>
<INPUT TYPE="hidden" value="04/14/02" name="checkbox1hid1dt1"> 04/14/02
</td>
<td >
<INPUT TYPE="hidden" value="421" name="checkbox1hid1lk"><a href="#">421</a>
</td>
<td >
<INPUT TYPE="hidden" value="$123,456,789.00" name="checkbox1hid1amt1">
$123,456,789.00
</td>
<td >
<INPUT TYPE="hidden" value="$1500.00" name="checkbox1hid1amt2">
$1500.00
</td>
<td >
<INPUT TYPE="hidden" value="$1000.00" name="checkbox1hid1amt3">
$1000.00
</td>
</tr>
<tr>
<td>
<INPUT type="checkbox" id=checkbox2 name=checkbox2 value="item2">
</td>
<td>
<INPUT TYPE="hidden" value="05/14/02" name="checkbox1hid2dt1"> 04/14/02
</td>
<td >
<INPUT TYPE="hidden" value="422" name="checkbox1hid2lk"><a href="#">421</a>
</td>
<td >
<INPUT TYPE="hidden" value="$1256,456,789.00" name="checkbox1hid2amt1">
$123,456,789.00
</td>
<td >
<INPUT TYPE="hidden" value="$15560.00" name="checkbox1hid2amt2">
$1500.00
</td>
<td >
<INPUT TYPE="hidden" value="$78.00" name="checkbox1hid2amt3">
$1000.00
</td>
</tr>
<tr>
<td>
<input type="Submit" value="Submit" id=submit1 name=submit1>
</td>
</tr>
</table>
</form>
<P> </P>
</BODY>
</HTML>
========================== ========== ========== ========== ===
==========================
<HTML>
<HEAD>
<TITLE></TITLE>
<script>
function jump()
{
var index=document.form1.Contr
var temp=document.form1.Contro
alert(temp);
document.form1.action=temp
document.form1.submit();
}
</script>
</HEAD>
<BODY>
<form NAME="ControlPanelForm" method=POST id=form1 name=form1 >
<table >
<tr>
<td>
<select name="ControlPanelOne" onchange=jump();>
<option selected>Choose Option</option>
<option value="Reverse.jsp">Revers
<option value="Correct.jsp">Correc
</select>
</td>
</tr>
<tr>
<td>
<INPUT type="checkbox" id=checkbox1 name=checkbox1 value="item1">
</td>
<td>
<INPUT TYPE="hidden" value="04/14/02" name="checkbox1hid1dt1"> 04/14/02
</td>
<td >
<INPUT TYPE="hidden" value="421" name="checkbox1hid1lk"><a href="#">421</a>
</td>
<td >
<INPUT TYPE="hidden" value="$123,456,789.00" name="checkbox1hid1amt1">
$123,456,789.00
</td>
<td >
<INPUT TYPE="hidden" value="$1500.00" name="checkbox1hid1amt2">
$1500.00
</td>
<td >
<INPUT TYPE="hidden" value="$1000.00" name="checkbox1hid1amt3">
$1000.00
</td>
</tr>
<tr>
<td>
<INPUT type="checkbox" id=checkbox2 name=checkbox2 value="item2">
</td>
<td>
<INPUT TYPE="hidden" value="05/14/02" name="checkbox1hid2dt1"> 04/14/02
</td>
<td >
<INPUT TYPE="hidden" value="422" name="checkbox1hid2lk"><a href="#">421</a>
</td>
<td >
<INPUT TYPE="hidden" value="$1256,456,789.00" name="checkbox1hid2amt1">
$123,456,789.00
</td>
<td >
<INPUT TYPE="hidden" value="$15560.00" name="checkbox1hid2amt2">
$1500.00
</td>
<td >
<INPUT TYPE="hidden" value="$78.00" name="checkbox1hid2amt3">
$1000.00
</td>
</tr>
<tr>
<td>
<input type="Submit" value="Submit" id=submit1 name=submit1>
</td>
</tr>
</table>
</form>
<P> </P>
</BODY>
</HTML>
==========================
this is your
Reverse.jsp
========================== ========== ========== ==
<%!
String strcheck1="";
String strcheck2="";
String strdt="";
String stramt1="";
String stramt2="";
String stramt3="";
String strlnk="";
%>
<%
strcheck1 = request.getParameter("chec kbox1");
System.out.println("strche ck1"+strch eck1);
if (strcheck1 != null)
{
if(strcheck1.equals("item1 "))
{
strdt = request.getParameter("chec kbox1hid1d t1");
stramt1 = request.getParameter("chec kbox1hid1a mt1");
stramt2 = request.getParameter("chec kbox1hid1a mt2");
stramt3 = request.getParameter("chec kbox1hid1a mt3");
strlnk = request.getParameter("chec kbox1hid1l k");
%>
<TABLE>
<TR>
<TD><%=strdt%></TD>
<TD><A HREF="#"><%=strlnk%></A></ TD>
<TD><%=stramt1%></TD>
<TD><%=stramt1%></TD>
<TD><%=stramt1%></TD>
</TR>
<%}}
strcheck2 =(String) request.getParameter("chec kbox2");
System.out.println("strche ck1"+strch eck2);
if (strcheck2 != null)
{
if(strcheck2.equals("item2 "))
{
System.out.println("inside if");
strdt = request.getParameter("chec kbox1hid2d t1");
stramt1 = request.getParameter("chec kbox1hid2a mt1");
stramt2 = request.getParameter("chec kbox1hid2a mt2");
stramt3 = request.getParameter("chec kbox1hid2a mt3");
strlnk = request.getParameter("chec kbox1hid2l k");
%>
<TR>
<TD><%=strdt%></TD>
<TD><A HREF="#"><%=strlnk%></A></ TD>
<TD><%=stramt1%></TD>
<TD><%=stramt1%></TD>
<TD><%=stramt1%></TD>
</TR>
<%}
}
%>
</TABLE>
Reverse.jsp
==========================
<%!
String strcheck1="";
String strcheck2="";
String strdt="";
String stramt1="";
String stramt2="";
String stramt3="";
String strlnk="";
%>
<%
strcheck1 = request.getParameter("chec
System.out.println("strche
if (strcheck1 != null)
{
if(strcheck1.equals("item1
{
strdt = request.getParameter("chec
stramt1 = request.getParameter("chec
stramt2 = request.getParameter("chec
stramt3 = request.getParameter("chec
strlnk = request.getParameter("chec
%>
<TABLE>
<TR>
<TD><%=strdt%></TD>
<TD><A HREF="#"><%=strlnk%></A></
<TD><%=stramt1%></TD>
<TD><%=stramt1%></TD>
<TD><%=stramt1%></TD>
</TR>
<%}}
strcheck2 =(String) request.getParameter("chec
System.out.println("strche
if (strcheck2 != null)
{
if(strcheck2.equals("item2
{
System.out.println("inside
strdt = request.getParameter("chec
stramt1 = request.getParameter("chec
stramt2 = request.getParameter("chec
stramt3 = request.getParameter("chec
strlnk = request.getParameter("chec
%>
<TR>
<TD><%=strdt%></TD>
<TD><A HREF="#"><%=strlnk%></A></
<TD><%=stramt1%></TD>
<TD><%=stramt1%></TD>
<TD><%=stramt1%></TD>
</TR>
<%}
}
%>
</TABLE>
keep both the files in same directory and select reverse from ur drop down it will take u to to Reverse.jsp.it will display 1 row if u select 1 and 2 if selecte 2.
regards
regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ryancys
Thanks.
Ramani
Thanks.
Ramani
Thanks for grade 'A'.
if ((request.getMethod().equa
//change your HTML here
//Use request.getParameter("Cont
}
else {
//Show Original HTML here
}