Jump to content

<select> with default value


anilkumar

Recommended Posts

Hello all, I had the problem ussing <select> in html with default value.<select name="cars" onChange="gcr_sbmit();"><option selected="selected" value=""></option><option value="volvo">Volvo</option><option value="saab">Saab</option><option value="fiat">Fiat</option><option value="audi">Audi</option></select>I want to raise the event when the user does the selection, but the actual problem raises when the user selects the selected option with "" as value.I dont want to raise event for it, how can i get tht be done( i.e. i dont want to execute the gcr_submit function for tht selected value)Thanks,Regards,Anil.

Link to comment
Share on other sites

You could see if this helps:<html><head><script type="text/javascript">function comingsoon(){document.write("Comming soon<br />")}</script></head><body><select size="5"><option onclick="comingsoon()" disabled>test<option onclick="comingsoon()" disabled>test2</select></body></html>

Link to comment
Share on other sites

<select name="cars" onChange="if (this.value) gcr_sbmit();"><option selected="selected">Select an option:</option><option value="volvo">Volvo</option><option value="saab">Saab</option><option value="fiat">Fiat</option><option value="audi">Audi</option></select>
Like this, there is no value for the selected (default) option. The function will only be called for options that do have a value :) Edited by Dan The Prof
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...