Link to home
Start Free TrialLog in
Avatar of zamirjalil
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("itemcheckbox");
        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.length;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]%><input type="hidden" name="price" value="<%=offer_pri$
      </tr>
        <% double price =0.00;
           price = Float.valueOf((String)offer_price[jj]).floatValue();
           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></font></div></td>
        <td align="center" valign="top" height="22"><%=df.format(totalprice)%>
        <input type="hidden" name="totalprice" value="<%=df.format(totalprice)%>"/></td>
      </tr>

    </table>
    <!------------- End Item List ----------------->
  </div>


Thank you in advance.

zamir
ASKER CERTIFIED SOLUTION
Avatar of kennethxu
kennethxu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zamirjalil
zamirjalil

ASKER

kenn, I think 20 point is too much you man..
just kidding  :)