user1892770
user1892770

Reputation: 333

javascript works in Chrome does not work in IE

In Chrome browser, when you click on CloudCover on this web page, a description is revealed below. In IE the description is not revealed. Any suggestions to make this work in IE?

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>min test</title>
        <script type='text/javascript'>
            function showDescription (sel) {
                var myVarDescip, myVarTEXT;
                var myVar = (sel.value);
                document.getElementById('putDescriptionHere').innerHTML = "";
                myVarDescip = (myVar + "Descrip");
                myVarTEXT = document.getElementById(myVarDescip).innerHTML;
                document.getElementById('putDescriptionHere').innerHTML = myVarTEXT;
            }
        </script>
    </head>
    <body>
        <select id="destSelect" size="3" multiple="multiple">
            <option value="CloudCover" onclick="showDescription(this);">Cloud Cover</option>
        </select>
        <div id="CloudCoverDescrip" style="display: none">
            <b>Cloud Cover:</b> The percentage of sky occluded by clouds.
        </div>
        <div id="putDescriptionHere"></div>
    </body>
</html>

Upvotes: 1

Views: 57

Answers (1)

adeneo
adeneo

Reputation: 318342

You can't attach mouse events on options in IE, so the click never fires.

Use the onchange event on the select instead

<select id="destSelect" size="3" multiple="multiple" onchange="showDescription(this);">

FIDDLE

Upvotes: 4

Related Questions