Click to See Complete Forum and Search --> : passing value in a form


okham
11-02-2003, 02:37 PM
...I'm trying to pass a value from a drop-down menu of a form to an <input..> in the same form, but I don't know what the value of the input should be; for instance, the code is:

<input type="hidden" name="item_number" value="">

Pattern<select name=pattern>
<option name=A selected>A
<option name=B>B</select>


All I want to do is pass the Pattern selection to the "item_number". Any suggestions?

okh

Khalid Ali
11-02-2003, 02:54 PM
Looks like this is exactly what you are looking for

Listbox populate text field (http://www.webapplikations.com/pages/html_js/forms/DropDownShowSelectionInTextField.html)

simpson97
11-02-2003, 03:56 PM
Try this:

<form name=form0>
<input type="text" name="item_number" value="">
Pattern
<select name=pattern
onchange="this.form.item_number.value = this.form.pattern.selectedIndex;">
<option name=A selected>A
<option name=B>B
<option name=C>C
</select>
</form>

Bob

okham
11-02-2003, 06:05 PM
...wow, Bob, I was hoping your suggestion would work because it was simple, but I'm afraid it didn't. I went and looked at the link Khalid pointed me too, but for some reason it's not working either. Here it is, if anyone could make a suggestion:

<form id="form1" action="" onsubmit="" style="margin:auto;">
<p>
<select name="prices" onchange="Process(this.options[this.selectedIndex].value)">
<option value="-1" >Select Price</option>
<option value="25.36" >25.36</option>
<option value="19.98" >19.98</option>
<option value="36.95" >36.95</option>
</select>
<input type="text" name="t1"/>
</p>
</form>

pyro
11-02-2003, 06:12 PM
Try this:

<form action="">
<p><select onchange="this.form.hidden.value = this.options[this.selectedIndex].value">
<option value="zero">0</option>
<option value="one">1</option>
<option value="two">2</option>
</select></p>
<p><input type="hidden" name="hidden" value="zero"></p>
</form>

okham
11-02-2003, 07:19 PM
...that worked, pyro. Please accept my humble thanks! Hope I can learn more as I go along...

okham

pyro
11-02-2003, 07:34 PM
Sure thing... Glad it worked for ya... :)