Click to See Complete Forum and Search --> : How to refer in ASP to the content of the text box portion of a dropdown list box
mpoincare
January 16th, 2003, 01:29 PM
I have on a web page a dropdown list with 3 values:
<option value "1" > United States </option>
<option value "2" > Canada </option>
<option value "3" > United Kingdom </option>
Now If the first country in the list is selected with value ="1", what ASP code can allow me to refer the label value wich in this case is "united states"?
GazDev
January 20th, 2003, 06:45 AM
If your combo box has an id of "MyCombo" then you'll use "MyCombo.value" (possibly "MyCombo.text").
If that doesn't work then, presuming that your combo is in a <FORM id="MyForm"> :
MyForm.MyCombo[MyForm.MyCombo.selectedIndex].value
When you say "refer in asp" you won't be able to if you mean the code within <% %>. But this is a client scripting forum so I guess you already know that!
GazDev
January 20th, 2003, 06:48 AM
You might want to use a <select> statement instead. The code I pasted for you refers to a <select> not <option>. You can set up the <select> statement in javascript like :
MyForm.MyCombo.length = 3;
MyForm.MyCombo.options[0].text = "Hello1";
MyForm.MyCombo.options[1].text = "Hello2";
MyForm.MyCombo.options[2].text = "Hello3";
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.