Veer
Veer

Reputation: 141

onclick check box not work

I made a script that onClick shows/ hides a dropdown list here is the code.

HTML:

 <input type="checkbox" name="user_choice" id="user_choice" onclick="checktoggle();"/>
 <label for="user_choice">Show Map</label>
 </br>
 <select name="radius_out_map" id="radius_out_map" style="display:none">
     <option value="0">-- Select Distance Radius --</option>
     <option value="10">10 Km.</option>
     <option value="20">20 Km.</option>
     <option value="50">50 Km.</option>
     <option value="100">100 Km.</option>
     <option value="300">300 Km.</option>
     <option value="500">500 Km.</option>
 </select> 

JAVASCTIPT :

<script language="javascript">
    function checktoggle() {
        var textboxid = document.getElementById('radius_out_map');
     if (textboxid.style.display == 'none') {
         textboxid.style.display = 'show';
     }
     else {
         textboxid.style.display = 'none';
     }
}
</script>

Why does this script not work?

Upvotes: 1

Views: 448

Answers (3)

Ashwin
Ashwin

Reputation: 12431

Change

textboxid.style.display = 'show'

to

textboxid.style.display = 'block'

show is not valid.

Upvotes: 0

Kshitij
Kshitij

Reputation: 8634

'show' is not valid. You will need to use 'inline' or 'block'

Upvotes: 2

mprabhat
mprabhat

Reputation: 20323

Instead of

textboxid.style.display = 'show'

Use this:

textboxid.style.display = 'block'

show is not a valid option for display, either use inline or block to show the element.

Check the list of valid values here

Upvotes: 5

Related Questions