Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assign value from a textbox to a drop down menu.

Status
Not open for further replies.

LucyL

Technical User
Feb 20, 2002
113
US
Hi, I have a function whereby if a checkbox is clicked the values in one set of textboxes are sent to another set of textboxes. For example, user enters payment details and if the address entered has the same shipping address, the details are sent to these fields.

However, how do I set a value for a drop down list?

function copyDislike()
{
window.document.editdetails.newdislike.selectedIndex = window.document.editdetails.dislike.value;
}

I have used the selected index property of the drop down in assigning a value to it, however its not functioning properly.
How do I mend this?
Thanx
 
I answered your other question (I think it is exactly the same) But this might be more like what you want.

<html>

<head>
<title>Test</title>
</head>
<body>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;&quot;>

<input type=&quot;text&quot; name=&quot;option_pick&quot; value=&quot;&quot;>
<input type=&quot;checkbox&quot; name=&quot;check_box1&quot; value=&quot;1&quot; onclick=select_option(document.form1.option_pick.value)>

<select name=&quot;hello&quot; size=1>
<option value=&quot;0&quot;></option>
<option value=&quot;1&quot;>First</option>
<option value=&quot;2&quot;>Second</option>
<option value=&quot;3&quot;>Third</option>
</select>

</form>


<script language=&quot;javascript&quot;>
function select_option(input){
//document.form1.hello.selectedIndex=input.value

if(input==&quot;1&quot;){
document.form1.hello.options[1].selected=true;

}else if (input==&quot;2&quot;){
document.form1.hello.options[2].selected=true;

}else if (input==&quot;3&quot;){
document.form1.hello.options[3].selected=true;

}

else{
alert(&quot;Value does not exist&quot;);
}

}

</script>

</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top