Event handling

message from lihaze on 21 Jul 2004
This is drivining me nuts! It works in FireFox but not IE6.
I've got an <select> and with a onChange and then a number of <option> and 1
of them has a onClick (tried a onSubmit but wouldn't work on either browser).
I've put in alerts for testing at this stage

Any ideas! Thanks in advance

<html>
<head>
<script language="JavaScript" type="text/JavaScript">

function toggleDisplay(){
window.alert("toggleDisplay");
}
function selectMulti(){
/* window.open("/hello.html", "selector", "height=300, width=400, top=10,
left=10,
ScrollBars=yes, resizable=yes, status=yes");
*/
window.alert("selectMulti");
}
</script>

</head>
<body>
<form name="blah" method="post">
<select name="rpAcc" class="body" onChange="toggleDisplay();">
<option value="ALL">All </option>
<option value="SELECTMULTIPLE" onClick="selectMulti();">Select
Multiple</option>
<option value="v">v</option>
<option value="zz">zz</option>
<option value="qw">qw</option>
</select>
</form>
</body>
</html>
 
lihaze replied to lihaze on 22 Jul 2004
cool. will give this a go.
any idea why it works fine in firefox?
 
Josh Johnson replied to lihaze on 21 Jul 2004
'Cuz firefox is a better browser. ;-)

Actually, it's kind of funny, because I wouldn't think it would work
there either, as you'd only execute a 'click' on the option if it's a
list selector, as opposed to a menu selector which would just get a
'mouseup'. Too many variables to keep track of, so I'm surprised it
works at all. Using onChange makes a whole lot more sense in general.

- Josh

lihaze wrote:
 
Josh Johnson replied to lihaze on 21 Jul 2004
You can't put an onclick on an option -- as you saw it won't work. What
var theValue = document.getElementById('rpAcc').value;
if(theValue == SELECTMULTIPLE) {
selectMulti();
}
- Josh

lihaze wrote:
 

Archived message: Event handling (Macromedia Dreamweaver)