zamirjalil
asked on
How to get the checkbox array value passed from another page?
Hi experts,
I have a page with a list of item need to be selected in order to proceed to the next page. And the next page should be displayed all the selected value, in my case the values are itemname,unit,quantity and offer_price. To do this, I check the checkbox parametervalues in the for statement, to know how many item was selected and then display the value of itemname,unit,quantity and offerprice. The problem is when I select the first row, it will display the corrent values of itemname...etc, but if I select the second or third row from itemlist, it still give a the value of the first row. Please help me how to solve this.
Below is the code:
<div align="center"> <br>
<!-- Start Item List -->
<%
String[] itemcheckbox = request.getParameterValues ("itemchec kbox");
String[] itemname = request.getParameterValues ("itemname ");
String[] unit = request.getParameterValues ("unit");
String[] quantity = request.getParameterValues ("quantity ");
String[] offer_price = request.getParameterValues ("price");
%>
<table border="0" width=600 cellpadding="3">
<tr bgcolor="#cecece">
<td height="22" colspan="4" align="center" valign="top"><font face=Verdana, Arial, Helvetica, sans-serif size="2" col$
List </strong></font></td>
</tr>
<tr>
<td width="40%" bgcolor=#f0f0f0 align="center" valign="top" height="22">
<font face=Verdana, Arial, Helvetica, sans-serif size="2" color=black>Item
Name</font></td>
<td width="18%" bgcolor=#f0f0f0 align="center" valign="top" height="22">
<font size="2" face="Verdana, Arial,Helvetica, sans-serif">Quantity</font ></td>
<td bgcolor=#f0f0f0 align="center" width="19%" valign="top"> <font face="Verdana, Arial, Helvetica, sans-serif" size=$
<td bgcolor=#f0f0f0 align="center" width="23%" valign="top" height="22">
<font face=Verdana, Arial, Helvetica, sans-serif size="2" color=black>Price
(RM) </font></td>
</tr>
<% double totalprice=0.00; %>
<% for(int jj=0;jj<itemcheckbox.lengt h;jj++) { %>
<tr>
<td align="center" valign="top" height="22"><%=itemname[jj ]%><input type="hidden" name="itemname" value="<%=itemname[$
<td align="center" valign="top" height="22"><%=quantity[jj ]%><input type="hidden" name="quantity" value="<%=quantity[$
<td align="center" valign="top" height="22"><%=unit[jj]%>< input type="hidden" name="unit" value="<%=unit[jj]%>"></td >
<td align="center" valign="top" height="22"><%=offer_price [jj]%><inp ut type="hidden" name="price" value="<%=offer_pri$
</tr>
<% double price =0.00;
price = Float.valueOf((String)offe r_price[jj ]).floatVa lue();
totalprice += price; %>
<%} %>
<% java.text.DecimalFormat df = new java.text.DecimalFormat("# .00"); %>
<tr>
<td height="22" colspan="3" align="center" valign="top"><div align="right">
<font face=Verdana, Arial, Helvetica, sans-serif size="2" color=black>
<strong>Total</strong></fo nt></div>< /td>
<td align="center" valign="top" height="22"><%=df.format(t otalprice) %>
<input type="hidden" name="totalprice" value="<%=df.format(totalp rice)%>"/> </td>
</tr>
</table>
<!------------- End Item List ----------------->
</div>
Thank you in advance.
zamir
I have a page with a list of item need to be selected in order to proceed to the next page. And the next page should be displayed all the selected value, in my case the values are itemname,unit,quantity and offer_price. To do this, I check the checkbox parametervalues in the for statement, to know how many item was selected and then display the value of itemname,unit,quantity and offerprice. The problem is when I select the first row, it will display the corrent values of itemname...etc, but if I select the second or third row from itemlist, it still give a the value of the first row. Please help me how to solve this.
Below is the code:
<div align="center"> <br>
<!-- Start Item List -->
<%
String[] itemcheckbox = request.getParameterValues
String[] itemname = request.getParameterValues
String[] unit = request.getParameterValues
String[] quantity = request.getParameterValues
String[] offer_price = request.getParameterValues
%>
<table border="0" width=600 cellpadding="3">
<tr bgcolor="#cecece">
<td height="22" colspan="4" align="center" valign="top"><font face=Verdana, Arial, Helvetica, sans-serif size="2" col$
List </strong></font></td>
</tr>
<tr>
<td width="40%" bgcolor=#f0f0f0 align="center" valign="top" height="22">
<font face=Verdana, Arial, Helvetica, sans-serif size="2" color=black>Item
Name</font></td>
<td width="18%" bgcolor=#f0f0f0 align="center" valign="top" height="22">
<font size="2" face="Verdana, Arial,Helvetica, sans-serif">Quantity</font
<td bgcolor=#f0f0f0 align="center" width="19%" valign="top"> <font face="Verdana, Arial, Helvetica, sans-serif" size=$
<td bgcolor=#f0f0f0 align="center" width="23%" valign="top" height="22">
<font face=Verdana, Arial, Helvetica, sans-serif size="2" color=black>Price
(RM) </font></td>
</tr>
<% double totalprice=0.00; %>
<% for(int jj=0;jj<itemcheckbox.lengt
<tr>
<td align="center" valign="top" height="22"><%=itemname[jj
<td align="center" valign="top" height="22"><%=quantity[jj
<td align="center" valign="top" height="22"><%=unit[jj]%><
<td align="center" valign="top" height="22"><%=offer_price
</tr>
<% double price =0.00;
price = Float.valueOf((String)offe
totalprice += price; %>
<%} %>
<% java.text.DecimalFormat df = new java.text.DecimalFormat("#
<tr>
<td height="22" colspan="3" align="center" valign="top"><div align="right">
<font face=Verdana, Arial, Helvetica, sans-serif size="2" color=black>
<strong>Total</strong></fo
<td align="center" valign="top" height="22"><%=df.format(t
<input type="hidden" name="totalprice" value="<%=df.format(totalp
</tr>
</table>
<!------------- End Item List ----------------->
</div>
Thank you in advance.
zamir
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
just kidding :)