PDA

View Full Version : Javascript in the options of a select box



molendijk
02-17-2011, 08:55 PM
1) CODE TITLE: Javascript in the options of a select box

2) AUTHOR NAME: Arie Molendijk

3) DESCRIPTION:
In non-IE, we can call functions from inside a select box by putting the following in the options of the box:
<option value="bla" onclick="some_function()"></option>

This is not possible in IE. So I created a script that works in both IE and non-IE and that allows us to do function calls from within select boxes whose options have text corresponding to the contents of any given script. Using the script, we can do things like:
<option value="some_function()" ></option>
<option value="window.open('http://www.google.com')" ></option>

4) URL TO CODE:
http://www.let.rug.nl/molendyk/selectbox_having_javascript_in_options/selectbox_having_javascript_in_options.html

vwphillips
02-27-2011, 03:52 PM
very good, I will make a note of it

molendijk
02-27-2011, 04:06 PM
Thanks,
Arie.