nick ha scritto:
<select id="one">
   <option value="1" selected>one</option>
   <option value="2">two</option>
   <option value="3">three</option>
</select>
The right syntax is :

<option value="1" selected="selected">one</option>

If there is no "selected" then it always defaults to first value. How
can I tell if the page has loaded and no options have been selected?
This is the way the select element works, there is always a selected element, even if you don't interact with the element.

You can do this:

<select id="one">
<option value="0">Select an option</option>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>

selected_val = parseInt($('#one').val());
if( selected_val == 0) {
  alert('please select an option');
} else {
  alert('You have selected :'+selected_val);
}

Bye

--
gianiaz.net - web solutions
via piedo, 58 - 23020 tresivio (so) - italy
+39 347 7196482

Reply via email to