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

Recommended Answers

All 5 Replies

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.

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.

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

<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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.