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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting both NAME and VALUE values from <OPTION> in ASP

Status
Not open for further replies.

jasonsalas

IS-IT--Management
Jun 20, 2001
480
GU
Hi everyone,

I've got a fairly large HTML form using:

<SELECT>
<OPTION value=&quot;School1&quot;>City1</OPTION>
<OPTION value=&quot;School2&quot;>City2</OPTION>
</SELECT>

Is there a way to extract both the the displayed text (i.e, City1), and the value held in the &quot;value&quot; attribute (i.e., School1&quot; using Request.Form?

Thanks!
 
I'll try to get you started.

Assuming that you name the <SELECT> and you wrap it in a <FORM>, you can access the property for the displayed text in a script.

FormName.SelectName.option(FormName.SelectName.SelectedIndex).text

When you submit, the form is going to automatically include the value. Your script will need to attach the text.

Somebody else will have to identify the script, I'm drawing a blank at the moment.
 
Try this in vbscript:

<select id=&quot;selTest&quot; onchange=&quot;doSelect()&quot; >
<option value=&quot;&quot;></option>
<option value=&quot;x&quot;>y</option>
<option value=&quot;a&quot;>b</option>
</select>
<SCRIPT LANGUAGE=vbscript>
<!--
sub doSelect()
msgbox selTest(selTest.selectedIndex).outerText
end sub
-->
</SCRIPT>

Use formName only if you have or need a form. This can be done in javascript as well. Jonathan Galpin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top