mikey3521 Posted November 22, 2007 Share Posted November 22, 2007 Hello. I have an image link on my page that is a button that will send a payment to payment gateway. Now I don't want them to be able to click it unless they put a checkmark in the box that says that've read and understand the TOA Is there anyway to have the image disabled by default.. BUT once they put a check in the checkbox it enables it but if they uncheck it re disables it? Thanks -Mike Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 22, 2007 Share Posted November 22, 2007 this should do the trick: <script language="javascript"> function errorMsg() { alert("You Must Agree To My TOS Agreement To Proceed"); } function go2pg() { document.getElementById('ticket').href="payment_gateway.php"; document.getElementById('tos').onclick=function() { donotgo2pg(); } } function donotgo2pg() { document.getElementById('ticket').href="javascript:errorMsg()"; document.getElementById('tos').onclick=function() { go2pg(); } } </script> <form> <input id="tos" type="checkbox" onclick="go2pg()"> I Agree To Your TOS Agreement </form> <a id="ticket" href="javascript:errorMsg()"><img src="gateway_submission.jpg" width="100" height="30" border=0 alt="Pay Now"></a> Quote Link to comment Share on other sites More sharing options...
mikey3521 Posted November 22, 2007 Author Share Posted November 22, 2007 Thank you very much. Though I still need a bit more to get there, I've got the basic idea of what's going on but the image I want to disable is actually the submit button. let me show you the code.. <input type=hidden name="testmode" value="on" /> <input type="checkbox" name="tos" value="ON">Agree? <input type=hidden name="merchantAccount" value="omitted"> <input type=hidden name="amount" value="399.99"> <input type=hidden name="item_id" value="testproduct"> <input type=image disabled name="cartImage" id="cartImage" src="http://solidtrustpay.com/images/buttons/buttontinySTP.gif"> </form> so basically if theres a checkbox in that TOS then i'll be able to click on the image, (submit input type, last line) if there is no check box, it's disabled (as it is now)... thoughts? Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 22, 2007 Share Posted November 22, 2007 see how this works out for you: <script language="javascript"> function check4check() { if (document.processor.tos.checked != true) { document.getElementById('cartImage').disabled = true; } else { document.getElementById('cartImage').disabled = false; } } </script> <form name="processor" action="process_gateway.php" method="post"> <input type=hidden name="testmode" value="on" /> <input type="checkbox" name="tos" value="on" onclick="check4check()">Agree? <input type=hidden name="merchantAccount" value="omitted"> <input type=hidden name="amount" value="399.99"> <input type=hidden name="item_id" value="testproduct"> <input type=image disabled name="cartImagepic" id="cartImage" src="http://solidtrustpay.com/images/buttons/buttontinySTP.gif"> </form> Quote Link to comment Share on other sites More sharing options...
mikey3521 Posted November 22, 2007 Author Share Posted November 22, 2007 Your my hero, worked like a charm. Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.