fubarur Posted December 8, 2008 Share Posted December 8, 2008 Thanks in advance for any help... I have a cart page the shows a subtotal CartSession::subtotal_cost() I want to make it so if the subtotal is below $50 it opens a Popup to send the user a message? popup page is /popup/50.php else no popup Any ideas? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/136067-solved-if-statment-with-popup-newbie-needs-help/ Share on other sites More sharing options...
Adam Posted December 8, 2008 Share Posted December 8, 2008 You'd need to use JavaScript. Whatever the total is displayed in (ie. input / div / etc) give it an ID. In the body 'onload' event call a JavaScript function to retrieve the value of the content in that ID. Parse the data to give you the actual total and if that's below 50, display the pop up. You'll find plenty of help on each step through Google! Adam Quote Link to comment https://forums.phpfreaks.com/topic/136067-solved-if-statment-with-popup-newbie-needs-help/#findComment-709478 Share on other sites More sharing options...
fubarur Posted December 8, 2008 Author Share Posted December 8, 2008 Correct I know I need to use Java, I guess what I'm looking for is help on how to set up the if statement? and where to place the call for the java Quote Link to comment https://forums.phpfreaks.com/topic/136067-solved-if-statment-with-popup-newbie-needs-help/#findComment-709706 Share on other sites More sharing options...
premiso Posted December 8, 2008 Share Posted December 8, 2008 Not really a "php" question, but I will help anyhow. <script type="text/javascript"> <!-- function mySubmit() { if (document.getElementyById('subTotal').value < 50) { window.open(); } document.test.submit(); // submit the form. } // --> </script> <form name="test" method="post" action="yourpage.php"> <input type="subTotal" value="" /> <input type="submit" name="submit" onClick="mySubmit();" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/136067-solved-if-statment-with-popup-newbie-needs-help/#findComment-709713 Share on other sites More sharing options...
fubarur Posted December 8, 2008 Author Share Posted December 8, 2008 Thanks premiso, Not what I'm looking for, my issue is more of a PHP not a form to allow someone to enter a value. So if someone adds a item to their cart that costs $20 a popup window pops and and says something like get a better shipping rate by adding more than $50 If they had more than $50 in the cart nothing would happen. This is what displays the subtotal on the page CartSession::subtotal_cost() Thanks Quote Link to comment https://forums.phpfreaks.com/topic/136067-solved-if-statment-with-popup-newbie-needs-help/#findComment-709779 Share on other sites More sharing options...
MadTechie Posted December 8, 2008 Share Posted December 8, 2008 Assuming this is on a loading page.... you could do this <?php $x =CartSession::subtotal_cost(); if($x < 50) { //JS or CSS or HTML message echo '<script type="text/javascript">'; echo 'alert("Spend more money");'; echo '</script>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/136067-solved-if-statment-with-popup-newbie-needs-help/#findComment-709953 Share on other sites More sharing options...
fubarur Posted December 11, 2008 Author Share Posted December 11, 2008 Perfect, thanks a ton! Quote Link to comment https://forums.phpfreaks.com/topic/136067-solved-if-statment-with-popup-newbie-needs-help/#findComment-712877 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.