View Full Version : check if any of the options value consist of

10-13-2005, 03:04 PM
if i have a
<option 1>
<option 2>
</select> in my html page
how can I check if any of the options consist a specific word?

10-13-2005, 08:15 PM
function f() {
var sel = document.getElementById('sel');
for(var i=0; i<sel.childNodes.length; i++) {
if(sel.childNodes[i].text == 'rotten') {
alert('I found you! (position:' + i + ')');

<select id="sel">
<button onclick="f();">Press Me</button>