k1point618 Posted March 10, 2011 Share Posted March 10, 2011 I'm writing a survey website and would like a pup up warning if the survey is not completed upon submitting. I'm new to PHP and I'm not really sure how to go about this. Thank you everyone! Quote Link to comment https://forums.phpfreaks.com/topic/230150-pop-up-window-in-php/ Share on other sites More sharing options...
trq Posted March 10, 2011 Share Posted March 10, 2011 PHP executes on the server, you need to use a client side language (Javascript) to execute anything in the browser. Quote Link to comment https://forums.phpfreaks.com/topic/230150-pop-up-window-in-php/#findComment-1185271 Share on other sites More sharing options...
dangerousprince Posted April 3, 2011 Share Posted April 3, 2011 Yeah, easiest thing to use is jQuery along side php with GET['msg']; variables. That way you can use PHP to get what popup you want, and then use jQuery and a little CSS to make them appear =] Example: <div class="disable"></div> <? if(isset($_GET['msg'])) { ?> <div class="popup" id="msg"> <div class="cross">x</div> <? // eventualy make it so it collects the items from the database so it can be updated without having to update the page ?> <h3>System message</h3> <? switch($_GET['msg']) { case 0: // Automatic email to be send to admin and shown that it has been noted and that the error should go away within a few hours. echo "An unexpected error occoured. Please notify the administrator."; break; case 1: echo "Your file was uploaded sucsessfully."; break; case 2: echo "An error occoured when the server was uploading your file. Please check the file and try again."; break; case 3: echo "Your file is not a valid CSV. Please check the file and try again."; break; } ?> <div class="clear"></div> <? //rather than save, create confirm button which confirms all the data and then add into the database ?> </div> <? } ?> Also, here's a little CSS you can use (style.css - or wherever): .popup h3 { margin-top:0; } .button { color:#fff; padding:0 10px; width:auto !important; height:27px !important; border:1px #e9e9eb solid !important; background:url(../images/l_bg.jpg) repeat-x; } .cross { right:0; cursor:pointer; margin-right:30px; position:absolute; padding:0 4px 1px 4px; border:1px #999 solid; } .disable { z-index:3; width:100%; height:100%; display:none; position:fixed; background:url(../images/disable.png) repeat; } And the jQuery if you need it (js/msg.js): $(document).ready(function(){ $(".disable").fadeIn("slow"); $("#msg").fadeIn("slow"); }); And to save some loading time, use this to add in the jQuery so you're only loading it when it's needed: <? if(isset($_GET['msg'])) { ?><script type="text/javascript" src="js/msg.js"></script><? } ?> Quote Link to comment https://forums.phpfreaks.com/topic/230150-pop-up-window-in-php/#findComment-1196237 Share on other sites More sharing options...
dangerousprince Posted April 3, 2011 Share Posted April 3, 2011 Oh yeah, and the last bit of jQuery when they click on the cross: $(".cross").click(function(){ $(this).parent().fadeOut("slow"); $(".disable").fadeOut("slow"); }); Hope that helps! Quote Link to comment https://forums.phpfreaks.com/topic/230150-pop-up-window-in-php/#findComment-1196238 Share on other sites More sharing options...
FlannelBeard Posted April 5, 2011 Share Posted April 5, 2011 PHP is a server side language, Java or Jquery would be would best. Another alternative is Lightbox, Fancybox, Darkbox, etc. You can download Lightbox here http://www.huddletogether.com/projects/lightbox2/[/i]]http://www.huddletogether.com/projects/lightbox2/. Very easy to implement. I prefer Fancybox for its use of inline frames within the java window, but it all depends on what you want to accomplish. dangerousprince, great script! I can use that for myself in the new site im building. Props for the custom CSS Also, try looking into ajax. You might be able to load your content through a div when you click on a link. You can set a drop shadow of like 20, block, 80% alpha and then dynamically load your "pop up". Just a thought if you arent comfortable with java. Quote Link to comment https://forums.phpfreaks.com/topic/230150-pop-up-window-in-php/#findComment-1197193 Share on other sites More sharing options...
KevinM1 Posted April 5, 2011 Share Posted April 5, 2011 PHP is a server side language, Java or Jquery would be would best. You mean JavaScript. Java is an object oriented language which runs on a virtual machine. It was created by Sun Microsystems. JavaScript is a scripting language which runs in a browser. It was created by Netscape. Aside from the name, which was Netscape merely trying to jump on board the hype Java was getting at the time, the two languages have nothing to do with one another. Quote Link to comment https://forums.phpfreaks.com/topic/230150-pop-up-window-in-php/#findComment-1197199 Share on other sites More sharing options...
FlannelBeard Posted April 5, 2011 Share Posted April 5, 2011 Meant Java as in Java'script'. Coder shorthand, so to speak but a good note to point out the difference for all beginners. Java'script' is what I meant, and using dangerousprince's code you should be able to create what you're looking for. You can tweak the css easily, if needed. Also, look into using jquery. You can do a lot of what youre talking about with some codes they give on the site with some instruction. Quote Link to comment https://forums.phpfreaks.com/topic/230150-pop-up-window-in-php/#findComment-1197232 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.