vikaspa Posted February 13, 2011 Share Posted February 13, 2011 I have page for checkout ( shopping cart) When person leaves a page I have a javascript called which gives alert Are you sure you want to leave this page? OK and Cancel button Which works fine However I donot want this alert when shopping cart is empty or I want this alert only when the page is left with entries in shopping cart Quote Link to comment https://forums.phpfreaks.com/topic/227511-conditional-call-when-page-leave/ Share on other sites More sharing options...
lastkarrde Posted February 13, 2011 Share Posted February 13, 2011 Well you need to show some code.. Quote Link to comment https://forums.phpfreaks.com/topic/227511-conditional-call-when-page-leave/#findComment-1173524 Share on other sites More sharing options...
denno020 Posted February 13, 2011 Share Posted February 13, 2011 You'll most likely have to use ajax to get the status of the shopping cart. Or, you could use php to check if there are any items in the cart, and if there is, echo the javascript code for the alert, otherwise, don't echo it, so therefore it won't run. If that makes sense? Denno Quote Link to comment https://forums.phpfreaks.com/topic/227511-conditional-call-when-page-leave/#findComment-1173556 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.