Can someone please tell me why this code isn't working? I'm fiddling around with designing a site and trying to get my JS bearings down. I'm wondering why the second option isn't making the drop down list disappear. Thanks in advance!

<html>
<head>
</head>
    <script language="JavaScript">
        function fncShow()
        {
           document.getElementById('box').style.visibility = 'visible';
        	
        }
 
       function fncHide()
        {
            document.getElementById('box').style.visibility = 'hidden';
        	
        }
    </script>
     
<body>
 
    <select name="box">
    <option selected>Choose one</option>
    <option value="first" onclick="JavaScript:fncShow();">first option</option>
    <option value="second" onclick="JavaScript:fncHide();">second option</option>
    </select>
</body>
</html>

Line 1 - No document type?

Line 2 - You forgot to add <title>MyTitle</title> element

Line 4 to 16 - Your script needs to be either within the <head> or within the <body> tag

Line 20 - You did not add the id attribute:

<select name="box" id="box">

Line 21 - The correct syntax for having a option selected is selected="selected" (see reference)

~G

Line 1 - No document type?

Line 2 - You forgot to add <title>MyTitle</title> element

Line 4 to 16 - Your script needs to be either within the <head> or within the <body> tag

Line 20 - You did not add the id attribute:

<select name="box" id="box">

Line 21 - The correct syntax for having a option selected is selected="selected" (see reference)

~G

Gracias amigo!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.