Quote (Kagura @ 6 Apr 2014 10:19)
Hey, I am working on a project right now in JqueryMobile. It is a shopping cart that displays 10 items. The assignment spec says we need to use a tomcat server to write servlets(to send the final orders to).
The issue I am having is that I cannot figure out how to get the selected number of items when you hit add to cart. The page looks like this:
http://i.imgur.com/iRQKelN.png
My goal is to have the submit button get the number the user selected, and pass that to the page that will display the current contents of the cart. I tried using php but realized that tomcat doesn't allow php(whoops).
Ultimately I could use a servlet(we are required to write these for this assignment) but our goal is to only contact the server when we have the final order being submitted.
Is there some built in way that I can pass the value from this selected field? Or do I have to explore something like javascript to get the value, manipulate the page, and then change the page to the current cart?
If anyone could point me in the right direction I would really appreciate it.
The number you select is in a select/option tag right ?
If that's the case, just set an id to your select tag "<select id='qty'>....</select>"
And on the click event of your button, just get the value of your select : var qty = $('#qty').val();
Then, use this qty variable to pass it to another page or whatever you want.
PM me if you need more help