AW: [Javascript] readout option and compare

Peter Brunone peter at brunone.com
Tue Sep 6 10:52:15 CDT 2005


   You could do it like this (assuming you can pass the select object and the string to the function):

function getText(theSelect, theString) {
   return theSelect.options[theSelect.selectedIndex].text.indexOf(theString);
} 

...or something more tailored to your needs, but this is the basic method.

Cheers,

Peter

 From: "Michael Borchers" <borchers at tridem.de>

>function getText() {
var theSelect = document.forms[0].myselect;
return theSelect.options[theSelect.selectedIndex].text;
}
<

thanks peter,
and how do i compare with javascript, with the IndexOf function?

first optionnext optionanother one

let's say the string is "option" and we search it within theSelect.options[theSelect.selectedIndex].text
?!
____________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20050906/32bac6ce/attachment.htm>


More information about the Javascript mailing list