Enable Paypal link after authorization checkbox

Discussion in 'Web Design and Development' started by gonnabuyamac, Jul 29, 2009.

  1. macrumors 6502

    Joined:
    Sep 26, 2006
    #1
    I'm trying to figure out a way to have one of those 'by checking this box, you agree to the policies, etc.' checkboxes on a webpage that then enables them to click on the PayPal button on the same page, which takes them to PayPal to purchase the item.

    Anyone have an idea of a PHP script that could do something like this?
     
  2. Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    PHP can't do it alone. It requires JavaScript. PHP would just check things server-side. Though, you have to remember that some people have JavaScript required so you need to make sure the button is enabled by default, otherwise they won't be able to enable it when the check the box.

    HTML:
    <input type="checkbox" id="agree" name="chkbx">I so agree!!
    <input type="button" id="paypal" value="Paypal">
    PHP:
    <script type="text/javascript">

    function 
    Init() {
      
    document.getElementById('paypal').disabled true;
      
    document.getElementById('agree').onclick TogglePaypal;
    }
    function 
    TogglePaypal() {
      var 
    toggle document.getElementById('paypal').disabled;
      
    document.getElementById('paypal').disabled = !toggle;
    }
    window.onload Init;

    </script>
     

Share This Page