d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Jquerymobile Help
Add Reply New Topic New Poll
Retired Moderator
Posts: 21,073
Joined: Apr 7 2008
Gold: 5,135.90
Trader: Trusted
Apr 6 2014 02:19am
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:


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.

Retired Moderator
Posts: 18,570
Joined: Feb 27 2004
Gold: 11,858.00
Trader: Trusted
Apr 6 2014 06:12pm
Have you figured it out?
Retired Moderator
Posts: 21,073
Joined: Apr 7 2008
Gold: 5,135.90
Trader: Trusted
Apr 7 2014 12:16am
Quote (Blind[zF] @ 6 Apr 2014 18:12)
Have you figured it out?


Right now I have to working with javascript. I just have an alert but I am going to use javascript to change the text in the dom tree, then change to that page.
I think it should work like this but havent got around to finishing it yet.
Member
Posts: 2,217
Joined: Sep 10 2007
Gold: 35.88
Apr 7 2014 08:15am
too bad you can't just use php
you could always create a hidden input, on submit select that hidden element, update it's value, then display said value where you want.
Member
Posts: 649
Joined: May 28 2012
Gold: 14.00
Apr 8 2014 06:18am
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
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll