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!

GET TEXT OFF SELECT

Status
Not open for further replies.

100dtl

Programmer
Aug 18, 2003
313
GB
Is it possible to get the text from this select with its id value?

<OPTION value=6>ABERAERON</OPTION>
<OPTION value=7>ABERCHIRDER</OPTION>
<OPTION value=8>ABERCONWY</OPTION>
<OPTION value=9>ABERCRAVE</OPTION>
<OPTION value=10>ABERCYNON</OPTION>
<OPTION value=11>ABERDARE</OPTION>
<OPTION value=12>ABERDARON</OPTION>
<OPTION value=13>ABERDEEN</OPTION>
<OPTION value=14>ABERDOUR</OPTION>
<OPTION value=15>ABERDOVEY</OPTION>
<OPTION value=16>ABERFELDY</OPTION>
 
<html>
<head>
<script language=&quot;javascript&quot;>
function getOptText(){
var objSel=document.getElementById(&quot;MyTest&quot;);

alert(objSel.options(objSel.selectedIndex).innerText);
}
</script>
</head>
<body>
<select id=&quot;MyTest&quot; onchange=&quot;getOptText()&quot;>
<OPTION value=6>ABERAERON</OPTION>
<OPTION value=7>ABERCHIRDER</OPTION>
<OPTION value=8>ABERCONWY</OPTION>
<OPTION value=9>ABERCRAVE</OPTION>
<OPTION value=10>ABERCYNON</OPTION>
<OPTION value=11>ABERDARE</OPTION>
<OPTION value=12>ABERDARON</OPTION>
<OPTION value=13>ABERDEEN</OPTION>
<OPTION value=14>ABERDOUR</OPTION>
<OPTION value=15>ABERDOVEY</OPTION>
<OPTION value=16>ABERFELDY</OPTION>
</select>
</body>
</html>

MrGreed

&quot;did you just say Minkey?, yes that's what I said.&quot;
 
Can this be done when the form is submitted to another page?
 
You have to decide if you send ID or the Text and make at the server side conversion. Or can use this trick
Code:
<OPTION value=&quot;6##ABERAERON&quot;>ABERAERON</OPTION>
<OPTION value=&quot;7##ZZZZZZZZZ&quot;>ZZZZZZZZZ</OPTION>

on server side now
selval=Split(Request(&quot;myselectobject&quot;),&quot;##&quot;)
id=selval(0)
text=selval(1)


________
George, M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top