...

View Full Version : option tag with javascript in IE6 issue



andydrizen
01-17-2009, 07:58 PM
Hi, I want to use the following code. In Firefox it works as I want it to, but in IE6 the javascript doesn't work - could anybody suggest a fix for me?


<select size='3' >
<option onmousedown='javascript:alert("you selected ONE");'>ONE</option>
<option onmousedown='javascript:alert("you selected TWO");' disabled='disabled'>TWO</option>
<option onmousedown='javascript:alert("you selected THREE");'>THREE</option>
</select>



Thanks,
Andy

Philip M
01-17-2009, 08:24 PM
Try this:-


<form name= "myform">
<select name = "optList" onchange = "showChoice()" size='3' >
<option value = "ONE" >ONE</option>
<option value = "TWO">TWO</option>
<option value = "THREE">THREE</option>
</select>
</form>

<script type = "text/javascript">

function showChoice() {
var pick = document.myform.optList.value;
alert ("You selected " + pick)
}
</script>


We have been asked to correct our report on the wedding last week. On return from honeymoon the happy couple will be staying at The Old Manse and not as we stated at the home of the bridegroom's father. - Newspaper paragraph.

andydrizen
01-17-2009, 08:36 PM
Thanks :-) That deals with most of it - what about keeping one field disabled?

Philip M
01-17-2009, 09:09 PM
Thanks :-) That deals with most of it - what about keeping one field disabled?

I am not too clear why you would want to do that (surely an option is an option?) but for an explanation of an IE bug see:-

http://www.lattimore.id.au/2005/07/01/select-option-disabled-and-the-javascript-solution/

Or you might try something like:-


<script type = "text/javascript">

function showChoice() {
var pick = document.myform.optList.value;
alert ("You selected " + pick);
if (pick == "ONE") {
alert ("That option is not available");
return false;
}
}
</script>

andydrizen
01-18-2009, 12:32 AM
Thanks for your assistance :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum