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?
1 reply to this topic
#1
Posted 11 June 2011 - 07:37 PM
|
|
|
#2
Posted 12 June 2011 - 12:54 AM
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


Sign In
Create Account


Back to top









