This works and will turn the pulldown menu red when the page shows:
Code:
<body>
<select name="date" class="styled">
<option value="">---</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
</select>
<script>
$.each(document.getElementsByTagName("select"),function(a,b){b.style.backgroundColor="#fdd";b.style.borderColor="#f66"});
</script>
</body>
If I change it so that it changes the color of the pulldown in response to pressing the submit button, it won't change the color of the pulldown menu itself, but when you click the menu all the items will be red. This is basically a validation that will turn the items in the form red if they need to be corrected.
Code:
<body>
<script>
$("#form_signup").live("submit", function() {
$.each(document.getElementsByTagName("select"),function(a,b {b.style.backgroundColor="#fdd";b.style.borderColor="#f66"});
};
</script>
<form id="form_signup" action="" method="post">
<select name="date" class="styled">
<option value="">---</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
</select>
<input type="submit" value="Go" />
</form>
</body>
If I take out 'class="styled"' from the code it works properly in both cases though, but of course I don't get the pulldown menus looking how I want them to. Any suggestions on how I can get this working?
Bookmarks