PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 23, 2022

[FIXED] How to show the tick mark after clicking the popup button in Jquery?

 August 23, 2022     checkbox, javascript, jquery, magento2, popup     No comments   

Issue

In my "Terms and conditions" pop up window, my requirement is to show the tick mark after closing the pop-up. It is happening only when we click the checkbox. Below is my code for terms and conditions,

Main HTML page:

 <div class="checkout-agreement">
    <input type="checkbox" class="required-entry">
    <label class="label">
        <button type="button" class="action action-show">
            <span>I agree the Terms Conditions</span>
        </button>
    </label>
</div>

Popup window:

<div class="modal-inner-wrap">
    <header class="modal-header">

        <button class="action-close" data-role="closeBtn" type="button">
            <span>Close</span>
        </button>
    </header>
    <div class="modal-content">
        <div id="checkout-agreements-modal">
                <div>
                    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
                </div>
        </div>
    </div>

    <footer class="modal-footer">

        <button class="action secondary action-hide-popup" type="button" "><span>Close</span></button>
            
        </footer>
        
    </div>

jQuery Code:

$('.checkout-agreement').modal({
    ...
    closed: function (){
       // Do some action when modal closed
    }
});

enter image description here enter image description here enter image description here Please give me suggestions to make this work.


Solution

$(document).ready(function(){
    $(document).on("click", ".action-close, .secondary", function(){
    $(".termscondchbox").removeAttr("disabled");
    $('.termscondchbox').prop('checked', true);
  });
  
  $(document).on("click", ".termscondchbox", function(){
    $(this).attr("disabled", true);
    $(this).prop('checked', false);
  });
});
<script src="https://code.jquery.com/jquery-3.5.1.js" integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=" crossorigin="anonymous"></script>

<div class="checkout-agreement">
  <input type="checkbox" class="required-entry termscondchbox" disabled="true">
  <label class="label">
            <button type="button" class="action action-show">
                <span>I agree the Terms Conditions</span>
            </button>
        </label>
</div>


<div class="modal-inner-wrap">
  <header class="modal-header">

    <button class="action-close" data-role="closeBtn" type="button">
            <span>Close</span>
        </button>
  </header>
  <div class="modal-content">
    <div id="checkout-agreements-modal">
      <div>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
          It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with
          desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
      </div>
    </div>
  </div>

  <footer class="modal-footer">

    <button class="action secondary action-hide-popup" type="button" "><span>Close</span></button>
            
        </footer>
        
    </div>



Answered By - Ejilarasan J
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing