populate a input field using a html combo-box
hello, i was wondering if anyone could help me find a way to allow a user to click items in a combo box and have its value populate an input field.
Thanks
brynFlew
Junior Poster in Training
59 posts since Jan 2011
Reputation Points: 27
Solved Threads: 1
give the input field an id. Set the combo box to call a function on change and pass the value to the function. Set that function to update the text field by id with the value received.
Can you figure it out from that or do you need all the code? I can't get that to you right now, maybe someone else can.
Im sure i can make it work, thanks for the advice, ill post back when i figure it out.
brynFlew
Junior Poster in Training
59 posts since Jan 2011
Reputation Points: 27
Solved Threads: 1
I wasnt able to figure it out, i am not very good with javascript, if you have some free time can you post some code as an example. This is what i tried anyway.
<option name="stop" id="stop"
<input id="eStop" name="eStop"
onchange="populateField(this.form)"
function populateField(frm){
test = frm.stop.value
alert('work' test)
frm.eStop.value = test
}
Thanks
brynFlew
Junior Poster in Training
59 posts since Jan 2011
Reputation Points: 27
Solved Threads: 1
<form>
<select name="sel1" onChange="populateField(this.form)" >
<option value="">---Select---</option>
<option value="stop" >Stop</option>
<option value="start">Start</option>
</select>
<input type="text" id="eStop" name="eStop" />
</form>
<script type="text/javascript">
function populateField(frm){
var test = frm.sel1.value;
alert('work '+ test);
frm.eStop.value = test;
}
</script>
It will work fine. Good luck.
mahavir123
Junior Poster in Training
95 posts since Sep 2010
Reputation Points: 11
Solved Threads: 35