954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Passing a drop down list item's value

Hello all,

I hope this isn't a silly question. I'm not much of a programmer {gulp} however I have a problem. I have a drop down list with 10 items, all different values. I'd like to be able to pass the value from a selected item in the list with a Click to order buton?

Here is the code I have thus far:
[html]


Quantity:
12345678910



mc_vs_accpt_h_023_gif.gif



[/html]
What do I need to do to get the value selected in the drop down list posted in the ?????? value area? I hope this isn't a huge deal. With my luck it probably is.

Thanks a ton!!
Chris

PS - Everyone can see the page as it looks by visiting: www.nationalbias.com/test/aqua_pad3.html

canilucas
Newbie Poster
3 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

There is no reason to do that, as the selected value will be posted with the form. You don't have to place it in a hidden variable.

However, in JavaScript it might look like this:

s = document.getElementById("quanity");
document.getElementById("ssl_amount").value = 
s.options[s.options.selectedIndex].value;


Untested, but should get you on the right track.

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

So, and forgive my ignorance here, where would I place this code in the code that I've shown? Or would it be placed somewhere else within my code? Sorry for my lack of knowledge. I know how to make a page look good, it's the functions like this that I really have not a clue.

Thank you,
Chris

canilucas
Newbie Poster
3 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 
tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

I think what tgreer's getting at is that you have to have some backend code to actually do anything with the value. The value of the control gets submitted on the page postback. What happens with the variable all has to do with backend stuff. In tgreer's example, he was using client-side JavaScript.

What platform are you working on? Are you using Perl? Python? ASP? Once you've got the value, you have to do something with it, and how you reference that value depends on what you want.

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 

Well, yes, eventually, the form will be filled out and all the form's values posted back to the server, where some server-side code will process it. I assumed that much.

It seems, though, that the user was asking how to move the value around within the form, prior to posting the form back to the server.

I don't know why, but my code shows how to do that. This one gets a big "shrug" from me... I think we've answered the threadstarter's question, and haven't heard any feedback, so...

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

Sorry to all who have answered or responded to this thread. I've attained what I've set out to do using all your suggestions. I've learned a lot thansk to all of your responses.

THANK YOU! Sorry It's taken me a bit to update you on my progress with my issue.
Chris

canilucas
Newbie Poster
3 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

you can just show your balls to ask questions without hesitant. the result depends on the availability of volunteers to help you before you worry about the "others".

pvt_geeker
Newbie Poster
3 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You