View Full Version : Combo box selection setting several hidden form values

12-01-2005, 05:22 AM
I posted this in the javascript forum thinking that the solution would most likely involve it. But as I thought that since it that my post seems to have mustarded little interest there, I would post here as well. Any thoughts would be welcomed.

I would like to be able to select a value (product) from a combo list and then have that selection dictate the value of several different hidden input variables in a form when submitted. I am interfacing with a third party payment processor and the data necessary to process the payment must be assigned to its predefined variables. For example, a user would see and be able to select one of the following:

Combo List \/
-Small Bracket
-Large Bracket

But when the selection is made I need to be able set values like these in my form when I click Submit (Buy Now):

<input type=’hidden’ name=’product_description’ value=[Set This Value]
<input type=’hidden’ name=’product_cost’ value=[Set This Amount]
<input type=’hidden’ name=’product_shipping’ value=[Set This Amount]

I feel like this should be a simple request but every tutorial I find comes close to telling me what I need but is just not quite enough. I used to program a lot but it has been a few years since I done much. I am new to javascript but comfortable with programming logic. Any help anyone can provide would be greatly appreciated.

12-01-2005, 05:33 AM
So because you were impatient, you went and disregarded the forum rules about cross posting. Please be patient in the future. You aren't the only person asking help on the forums. There is only so much we can do. Threads slip by sometimes with out ever being answered.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
function changeValue(obj){
else if(obj.value=="lbracket"){
alert(document.forms[0].product_description.value)//you can remove this
alert(document.forms[0].product_cost.value)//you can remove this
alert(document.forms[0].product_shipping.value);//you can remove this

<form action="#" method="post">
<select name="item" onchange="changeValue(this)">
<option value="sbracket">Small Bracket</option>
<option value="lbracket">Large Bracket</option>
<input type="hidden" name="product_description" value="" />
<input type="hidden" name="product_cost" value="" />
<input type="hidden" name="product_shipping" value="" />

12-01-2005, 05:48 AM
My sincerest apologies, I meant no disrespect to this forum or its users. I highly value both the information and effort that is found here. I only posted in this tread in addition to the javascript thread because I was unsure if I had posted in the correct one to begin with. Your input is greatly appreciated, I thank you for your time, and again, I meant no disrespect.

12-01-2005, 07:42 AM
Posting additional questions in correct javascript thead posting here: http://www.codingforums.com/showthread.php?t=73774