Search
 
SCRIPT & CODE EXAMPLE
 

HTML

Html show and hide div


METHOD 1
=================
function myFunction() {
  var x = document.getElementById("myDIV");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }
}




METHOD 2
=================


<!--SELECT ELEMENT-->
<div class="form-group row">
    <label class="col-md-3 label-control" for="projectinput1"> <b>Group Type</b></label>
    <div class="col-md-4 mx-left">
        <select id="projectinput7" name="period1" class="form-control round" required="" onchange="select_group(this.value)">
            <option value="" selected="">- Select Group Type -</option>
            <option value="GROUP-SAVINGS">Cooperative Group Savings</option>
            <option value="GROUP-LOANS">Cooperative Group Loans</option>
        </select>
    </div>
</div>



<style>
    .showx{
        visibility: visible;
        display: block;
    }
    .hidex{
        visibility: hidden;
        display: none;
    }
</style>



<script>

    function select_group(group_type){

        var group_type;

        //alert(group_type);

        //GROUP SAVINGS
        if(group_type == 'GROUP-SAVINGS')
        {
            //show
            document.getElementById("payment_period").style.visibility = "visible";
            document.getElementById("payment_period").setAttribute("style", "showx");

            //hide
            document.getElementById("tenor").style.display = "none";
            document.getElementById("optional_info").style.display = "none";
        }

        //GROUP LOANS 
        if(group_type == 'GROUP-LOANS')
        {
            //show
            document.getElementById("payment_period").style.display = "none";
            document.getElementById("amount_payable").style.display = "none";
            document.getElementById("optional_info").setAttribute("style", "hidex");
            
            //hide
            document.getElementById("tenor").setAttribute("style", "showx");
            document.getElementById("optional_info").setAttribute("style", "showx");
        }
    }

</script>
Comment

hide and show div using javascript with example

hide and show divs using javascript
Comment

PREVIOUS NEXT
Code Example
Html :: what is markup in html 
Html :: hyperlinks in html 
Html :: wright word with < in html p tag 
Html :: how to set a var in js to be a download 
Html :: timetable html 
Html :: date range picker select date and several weeks 
Html :: html input for email 
Html :: how to detect play button on html video player 
Html :: elseif vuejs 
Html :: rick astley never gonna give you up 
Html :: html audio tag 
Html :: html code tag 
Html :: vue js v-for array index 
Html :: input onchange continuously 
Html :: remove extra whitespace in pre html 
Html :: bootstrap 4 tabs 
Html :: twig lower 
Html :: simple program of html 
Html :: how to resize all images in a class html 
Html :: radio buttons in bootstrap 
Html :: email validator hmtl 
Html :: mailchimp form action 
Html :: style font in html 
Html :: tailwind css range slider 
Html :: html table to pdf jquery 
Html :: handlerbars js conditional 
Html :: ng-container vue equvalent 
Html :: how to select the last type of an element in html 
Html :: indice html 
Html :: testimonial slider html 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =