Hi, I have a function which works fine by using a link e.g. <a href="javascript:;" onClick="change1('div1'); return false;">Change</a> Code (markup): But i want to adapt this to a selection list. I tried this but does not work. Please advise: <select name=""> <option value="shoes" onchange="change('div1'); return false;">shoes</option> </select Code (markup): Thank you in advance. Adam
You can use onclick for the option elements or alternatively use onchange on the select and handle the selected index or value. Using onclick for option elements means that if the selection is made using the keyboard the onclick event will (obviously) not be triggered. This can be avoided by using the onchange event on the select. Here's an example:- <html> <head> <script type="text/javascript"> function handleChange(sValue) { switch(sValue) { default: break; case '1': alert('One'); break; case '2': alert('Two'); break; } } </script> </head> <body> <select name="a" onchange="handleChange(this.value);"> <option value="">Please Select</option> <option value="1">One</option> <option value="2">Two</option> </select> </body> </html> HTML: