Hello All -
I'm having trouble getting the value of a select list option with jquery - I'm sure it's just the wrong conditional syntax.
I've been all over the web today on this question and can find some clues (maybe) to what I'm doing wrong, but nothing I've tried works.
What I want to do is determine the value of a particular select. If the value is "00" then I'll trigger an error.
Select code is here:
++++++++++
<select name="numberRooms" class="yellow">
<option value='00'>00</option>
<option value='01 Standard Room'>01</option>
<option value='02 Standard Rooms'>02</option>
<option value='03 Standard Rooms'>03</option>
</select>
++++++++++
jQuery code is here: (I think the problem area is in bold - but it may be elseware)
++++++++++
function checkRooms() {
if ($('select#numberRooms option:selected').val() == '00') {
$('select#numberRooms').css('background-color','#FFCCCC');
return false;
}
else {
$('select#numberRooms').css('background-color','#E4FFCA');
return true;
}
}
++++++++++
Greatly appreciate any guidance on where I'm going wrong.
Thanks to all in advance!