mercredi 14 juin 2017

Displaying Div without clicking radio button in update form

I have a form that uses JavaScript for displaying a div depending on what radio button was chosen. Now in my other form for the update, i'd applied the same java script but made few changes on displaying directly the div without clicking the radio button but it didn't work. How to do it correctly. Any help is much appreciated.

 <script type="text/javascript">
  function payment() {
    if (document.getElementById('installmentCheck').checked) {
      document.getElementById('installment').style.display = "block";
      document.getElementById('full').style.display = "none";
    }else if (document.getElementById('fullCheck').checked) {
      document.getElementById('full').style.display = "block";
      document.getElementById('installment').style.display = "none";
    }
  }
</script>


<div class="col-lg-6 ">
  <div class="form-group">
    <label class="control-label">
      Payment Scheme :
    </label>
    <div class="input-group ">
      <?php
      if ($scholarship->scholarship_payment != 'Full') {
        echo '<input type="radio" onclick="javascript:payment();" name="choosePaymentScheme" id="installmentCheck" value="Installment" checked > Installment &nbsp&nbsp&nbsp';
        echo '<input type="radio" onclick="javascript:payment();" name="choosePaymentScheme" id="fullCheck" value="Full"> Full';
      }else{
        echo '<input type="radio" onclick="javascript:payment();" name="choosePaymentScheme" id="installmentCheck" value="Installment" > Installment &nbsp&nbsp&nbsp';
        echo '<input type="radio" onclick="javascript:payment();" name="choosePaymentScheme" id="fullCheck" value="Full" checked> Full';
      }
      ?>
    </div>
  </div> 
  <div id="installment" style="display:none">
    <div class="form-group">
      <input type="text" name="Install" >
    </div>
  </div>
  <div id="full" style="display:none">
    <div class="form-group">
      <input type="text" name="full" >
    </div>
  </div>
</div>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire