Page 1 of 1

html/javascript problem

Posted: Fri Dec 19, 2008 2:05 pm
by mukul_chou
Moved to Client Side by moderator.

Hello...
I could not find out the appropriate forum to post this problem. It is not regarding php problem.

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" language="javascript">
    function displayValue(id)
    {
        val = document.getElementById(id).value;
        document.getElementById('disp').innerHTML = val;
    }
</script>
</head>
 
<body>
<div style="float:left;">
<form action="" method="get">
    <select id="mouseOver" name="mouseOver">
        <option id="A1" value="1" onmouseover="displayValue(this.id)">A</option>
        <option id="A2" value="2" onmouseover="displayValue(this.id)">B</option>
        <option id="A3" value="3" onmouseover="displayValue(this.id)">C</option>
        <option id="A4" value="4" onmouseover="displayValue(this.id)">D</option>
    </select>
</form>
</div>
<div id="disp" style="float:left;">
Display value
</div>
</body>
</html>
this bit of code is working fine in Firefox 3.xx but not in any other browser. The problem is the js function calling onmouseover="displayValue(this.id)" is not being invoked in other browser. I have checked it with 'alert()'. so does not the onmouseover event works in <option> tags?
........thanks in advance

Re: html/javascript problem

Posted: Fri Dec 19, 2008 2:48 pm
by pkbruker
Not quite the correct forum, but try:

onmouseover="javascript:displayValue(this.id)"