How To Show And Hide Input Fields Based On Radio Button Selection

前端 未结 8 1150

Here is the code to show input fields depending on radio selection like:

SCRIPT



        
相关标签:
8条回答
  • 2020-11-29 02:13

    Use display:none/block, instead of visibility, and add a margin-top/bottom for the space you want to see ONLY when the inputs are shown

     function yesnoCheck() {
            if (document.getElementById('yesCheck').checked) {
               document.getElementById('ifYes').style.display = 'block';
            } else {
               document.getElementById('ifYes').style.display = 'none';
            }
        }
    

    and your HTML line for the ifYes tag

    <div id="ifYes" style="display:none;margin-top:3%;">If yes, explain:
    
    0 讨论(0)
  • 2020-11-29 02:16

    Use display:none to not show the items, then with JQuery you can use fadeIn() and fadeOut() to hide/unhide the elements.

    http://www.w3schools.com/jquery/jquery_fade.asp

    0 讨论(0)
提交回复
热议问题