Jump to content

Shopping cart help

- - - - -

  • Please log in to reply
1 reply to this topic

#1
ahmed

ahmed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
I am making a little shopping cart using jsp . Now when the ORDER Page comes , it shows product names , prices , and quantity .
When the user selects the quantity and click checkout , the program should calculate the cost of it . Now how can i do that?
I have a form which i am populating with the product name and price , how can i calculate the selected product values?

#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
If you select them using checkboxes, give all the checkboxes the same name, and as value you give it the productId:
<form>

...

<input TYPE=checkbox name=[B][COLOR="#008000"]"product"[/COLOR][/B] value=[B][COLOR="#008000"]"carId"[/COLOR][/B]> car<br/>

<input TYPE=checkbox name=[B][COLOR="#008000"]"product"[/COLOR][/B] value=[B][COLOR="#008000"]"bookId"[/COLOR][/B]> book<br/>

...

</form>
And as you get the "product" out of the request, you get a String array containing the values from the selected checkboxes.
String[] productIds = request.getParameterValues([B][COLOR="#008000"]"product"[/COLOR][/B]);

Edited by wim DC, 12 June 2011 - 02:03 AM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users