| | |
Passing a drop down list item's value
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2006
Posts: 3
Reputation:
Solved Threads: 0
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]
<form action="https://www.viaKLIX.com/process.asp" method="post">
<p align="center">
<input type="hidden" name="ssl_merchant_id" value="654321">
<input type="hidden" name="ssl_user_id" value="aquapad">
<input type="hidden" name="ssl_pin" value="123456">
<input type="hidden" name="ssl_amount" value="??????">
<input type="hidden" name="ssl_customer_code" value="1">
<input type="hidden" name="ssl_cvv2" value="Present">
<input type="hidden" name="ssl_cvv2cvc2" value="">
<input type="hidden" name="ssl_invoice_number" value="Aqua1-001">
<input type="hidden" name="ssl_description" value="Aqua Pad - 5 pad package">
<span class="style9">Quantity:</span>
<select name="quantity" id="quantity">
<option value="9.25" selected>1</option>
<option value="15.00">2</option>
<option value="20.75">3</option>
<option value="26.50">4</option>
<option value="32.25">5</option>
<option value="38.00">6</option>
<option value="43.75">7</option>
<option value="49.50">8</option>
<option value="55.25">9</option>
<option value="61.00">10</option>
</select>
</p>
<p align="center"><input type="submit" value="Click To Order">
<br>
<br>
<a href="http://www.mastercard.com/" target="_blank"><img src="../images/mc_vs_accpt_h_023_gif.gif" width="75" height="23" border="0"></a></p>
</form>
[/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
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]
<form action="https://www.viaKLIX.com/process.asp" method="post">
<p align="center">
<input type="hidden" name="ssl_merchant_id" value="654321">
<input type="hidden" name="ssl_user_id" value="aquapad">
<input type="hidden" name="ssl_pin" value="123456">
<input type="hidden" name="ssl_amount" value="??????">
<input type="hidden" name="ssl_customer_code" value="1">
<input type="hidden" name="ssl_cvv2" value="Present">
<input type="hidden" name="ssl_cvv2cvc2" value="">
<input type="hidden" name="ssl_invoice_number" value="Aqua1-001">
<input type="hidden" name="ssl_description" value="Aqua Pad - 5 pad package">
<span class="style9">Quantity:</span>
<select name="quantity" id="quantity">
<option value="9.25" selected>1</option>
<option value="15.00">2</option>
<option value="20.75">3</option>
<option value="26.50">4</option>
<option value="32.25">5</option>
<option value="38.00">6</option>
<option value="43.75">7</option>
<option value="49.50">8</option>
<option value="55.25">9</option>
<option value="61.00">10</option>
</select>
</p>
<p align="center"><input type="submit" value="Click To Order">
<br>
<br>
<a href="http://www.mastercard.com/" target="_blank"><img src="../images/mc_vs_accpt_h_023_gif.gif" width="75" height="23" border="0"></a></p>
</form>
[/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
Last edited by tgreer; May 9th, 2006 at 11:35 pm. Reason: Yet another poster ignorning the instructions to use CODE tags.
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
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:
Untested, but should get you on the right track.
However, in JavaScript it might look like this:
HTML and CSS Syntax (Toggle Plain Text)
s = document.getElementById("quanity"); document.getElementById("ssl_amount").value = s.options[s.options.selectedIndex].value;
Untested, but should get you on the right track.
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Just to repeat, you do not have to do this. The selected value will already be posted, as the value of your "quantity" object.
But, if you want to move the value of one element, to another, you have to use JavaScript.
So the question is, where do I put this script, and the next question is, when does it run?
The answer to the first part is, create a JavaScript function, and place it in the head of your page:
[html]
<html>
<head>
<script type="text/javascript">
function movevalue()
{
s = document.getElementById("quantity");
document.getElementById("ssl_amount").value =
s.options[s.options.selectedIndex].value;
}
</script>
</head>
<body>
</body>
</html>
[/html]
Ok, so that places the script on the page, ready to run. When will it run? In response to an EVENT. The question you have to ask is, what event should cause this to run?
I would suggest perhaps when the user changes the value of the selected option. That event, "change", is handled by adding
But, if you want to move the value of one element, to another, you have to use JavaScript.
So the question is, where do I put this script, and the next question is, when does it run?
The answer to the first part is, create a JavaScript function, and place it in the head of your page:
[html]
<html>
<head>
<script type="text/javascript">
function movevalue()
{
s = document.getElementById("quantity");
document.getElementById("ssl_amount").value =
s.options[s.options.selectedIndex].value;
}
</script>
</head>
<body>
</body>
</html>
[/html]
Ok, so that places the script on the page, ready to run. When will it run? In response to an EVENT. The question you have to ask is, what event should cause this to run?
I would suggest perhaps when the user changes the value of the selected option. That event, "change", is handled by adding
onchange="movevalue();" to your select tag. Last edited by tgreer; May 10th, 2006 at 12:56 pm.
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.
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.
Alex Cavnar, aka alc6379
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
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...
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...
![]() |
Similar Threads
- Removing an item from head of linked list (C)
- Tutorial: Create a cross-browser compatible, single-level, drop-down menu (Site Layout and Usability)
- Please Help, Junk on machine (Windows NT / 2000 / XP)
Other Threads in the HTML and CSS Forum
- Previous Thread: Layers!
- Next Thread: Code to Hide TaskBar etc?
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form google griefers hackers hitcounter hover html ie7 ie8 iframe image images internet intranet iphone javascript jpeg layout macbook maps mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization pnginie6 positioning scroll seo shopping swf swf. textcolor timecolor titletags url urlseparatedwords visualization web webdevelopment webform website windows7






