visualazza Posted May 11, 2010 Share Posted May 11, 2010 Ive been racking my brain(s) for a while now about this. Does anyone know how i would go about setting up a system to create a popup box with a form inside that will have a unique id (retrieved from the database) in a hidden field for each result of a query, that when sent will perform a task related to the row with the unique id? Thanks, Kind Regards, Ashley Quote Link to comment https://forums.phpfreaks.com/topic/201350-popup-form-for-each-result-from-mysql-database/ Share on other sites More sharing options...
Adam Posted May 11, 2010 Share Posted May 11, 2010 You mean generate a link/button for each result of a query, that will then open a pop-up box containing a form with the hidden ID input? Quote Link to comment https://forums.phpfreaks.com/topic/201350-popup-form-for-each-result-from-mysql-database/#findComment-1056364 Share on other sites More sharing options...
visualazza Posted May 11, 2010 Author Share Posted May 11, 2010 i should also mention that i have created the popup content area, but im just trying to parse the id number to a hidden field on that form depending on which results link to open the popup area. Oh and yes you are right MrAdam. Just to clarify the popup box works like shadow box without opening another window. Quote Link to comment https://forums.phpfreaks.com/topic/201350-popup-form-for-each-result-from-mysql-database/#findComment-1056365 Share on other sites More sharing options...
Adam Posted May 11, 2010 Share Posted May 11, 2010 You'll probably just need to amend the function to pass the current ID. Could you show the function and how you call it? Quote Link to comment https://forums.phpfreaks.com/topic/201350-popup-form-for-each-result-from-mysql-database/#findComment-1056368 Share on other sites More sharing options...
visualazza Posted May 11, 2010 Author Share Posted May 11, 2010 it uses jquery and its not the whole code function loadPopup(){ //loads popup only if it is disabled if(popupStatus==0){ $("#backgroundPopup").css({ "opacity": "0.7" }); $("#backgroundPopup").fadeIn("slow"); $("#popupContact").fadeIn("slow"); popupStatus = 1; } } This is when you click the link or button $("#button").click(function(){ //load popup loadPopup(); }); Quote Link to comment https://forums.phpfreaks.com/topic/201350-popup-form-for-each-result-from-mysql-database/#findComment-1056375 Share on other sites More sharing options...
Adam Posted May 11, 2010 Share Posted May 11, 2010 I'd reccommend selecting the buttons using a class name, as apposed to the ID (you shouldn't have multiple elements with the same ID anyway). That way you can then store the unique ID in question as the ID of the element, and then pass that to the loadPopup() function: $(".popupButton").click(function(){ //load popup loadPopup(this.id); }); Then declare the ID parameter in your function: function loadPopup(the_id){ // with a more fitting name of course Now you have the unique ID available within the function. Just select the hidden input and update it's value.. This method may be a little fallible just plainly storing the ID like that, so you may want to prepend it with "result:" or something and strip that part out in the function.. your call. Quote Link to comment https://forums.phpfreaks.com/topic/201350-popup-form-for-each-result-from-mysql-database/#findComment-1056386 Share on other sites More sharing options...
visualazza Posted May 11, 2010 Author Share Posted May 11, 2010 thanks MrAdam, just a quick question, how do i pass over the this.id from loadPopup(this.id) into a hidden field ready for submition to a php script Quote Link to comment https://forums.phpfreaks.com/topic/201350-popup-form-for-each-result-from-mysql-database/#findComment-1056394 Share on other sites More sharing options...
Adam Posted May 11, 2010 Share Posted May 11, 2010 Well I assume the pop-up box HTML already exists in the document, judging by the code? You just need to select the hidden input you wish to store the ID in using jQuery's selector and set the value property: $('#hidden_input_id').value = the_id; Quote Link to comment https://forums.phpfreaks.com/topic/201350-popup-form-for-each-result-from-mysql-database/#findComment-1056395 Share on other sites More sharing options...
Adam Posted May 11, 2010 Share Posted May 11, 2010 Sorry, not thinking about jQuery. You'll need to use the attr() method to set the value: $('#hidden_input_id').attr('value', the_id); Quote Link to comment https://forums.phpfreaks.com/topic/201350-popup-form-for-each-result-from-mysql-database/#findComment-1056400 Share on other sites More sharing options...
visualazza Posted May 11, 2010 Author Share Posted May 11, 2010 is #hidden_input_id a class i put in the hidden field? Quote Link to comment https://forums.phpfreaks.com/topic/201350-popup-form-for-each-result-from-mysql-database/#findComment-1056401 Share on other sites More sharing options...
Adam Posted May 11, 2010 Share Posted May 11, 2010 No, think about CSS. "#" means an ID, although you'll want to use something a little more meaningful than "hidden_input_id". Edit: But yeah, you need to add it to the unique ID hidden field in your form. Quote Link to comment https://forums.phpfreaks.com/topic/201350-popup-form-for-each-result-from-mysql-database/#findComment-1056402 Share on other sites More sharing options...
visualazza Posted May 11, 2010 Author Share Posted May 11, 2010 yeah, sorry, i meant id. I think ive got it to work. Thanks ever sooo much. If ever you need help with anything with graphics such as banner or logos, video (with vfx) or any music or sounds then im your man. For all your help you can have anything you want. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/201350-popup-form-for-each-result-from-mysql-database/#findComment-1056407 Share on other sites More sharing options...
Adam Posted May 11, 2010 Share Posted May 11, 2010 Ha, no problem. Thanks.. Quote Link to comment https://forums.phpfreaks.com/topic/201350-popup-form-for-each-result-from-mysql-database/#findComment-1056409 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.