views:

136

answers:

2

hallo, can somebody help me. I try to make some thing happen when i click on anders(value 0), than something need to be vissible. It works in firefox but not in IE

<select id="budget" name="budget">
<option value="0" onclick="anders('1')">Anders</option>
<option value="200" onclick="anders('');" selected="selected">&#8364; 200,-</option>
<option value="300" onclick="anders('')">&#8364; 300,-</option>
<option value="400" onclick="anders('')">&#8364; 400,-</option>
<option value="500" onclick="anders('')">&#8364; 500,-</option>
<option value="600" onclick="anders('')">&#8364; 600,-</option>

can some body please help me? greetz banoth

+2  A: 

You should put an onchange event handler on the <select> instead of many onclick event handlers on the <option>s.

KennyTM
+1 - I was just writing up a code sample with this. IE doesn't support the `onclick` event for `<option>` tags.
Andy E
+1  A: 

Onclick is not a valid handler for option types. you need to use the onchange in the select box:

<select id="budget" name="budget" onchange="anders(escape(this.options[this.selectedIndex].value))">
<option value="0">Anders</option>
<option value="200" selected="selected">&#8364; 200,-</option>
<option value="300">&#8364; 300,-</option>
<option value="400">&#8364; 400,-</option>
<option value="500">&#8364; 500,-</option>
<option value="600">&#8364; 600,-</option>
</select>
Tim
What's the `escape()` for? Besides it being an outdated javascript method that doesn't support UTF-8, it seems completely unnecessary here and doesn't look like a true representation of the original code which used `anders('1')` for the first option's onclick.
Andy E
@OP; Or you could just use `this.value` instead of going through the whole `this.selectedIndex` bit
Douwe Maan