Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>check if any of the options value consist of

check if any of the options value consist of

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

rm-f
10-13-2005, 08:15 PM
<html>
<head>
<script>
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 + ')');
}
}
}
</script>

</head>
<body>
<select id="sel">
<option>good</option>
<option>better</option>
<option>rotten</option>
</select>
<button onclick="f();">Press Me</button>

</body>
</html>


 

TOP

For more info

setting a minimum size
Auto Preview of Image 
Refresh with a query s
JS Validation obsolete
Javascript Pop up func
Slide show transitions
I'm a newbie...please!
how to write coding in
Advanced Debug Info 
.js file doesn't work 

News Archive

Adding Graphic To Text
re-direct form after s
pop up window controls
Clock on homepage - He
passing a param from a
Password Procection wi
document.title in same
focus onload 
Counting Wrong from Ri
Help needed on how to 

Related stories:

help with rollover menu
Writing form data to another value in a different window
Onload in an iframe
Using Javascript to set Stylesheet based on Browser, not Recognized
hide elements based on ID
Session Timeout - javascript
check if one of a group of radio buttons have been checked
How to change the checked item on a radio type with javascript

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics