jake2891 Posted November 10, 2008 Share Posted November 10, 2008 Hi Guys, This is a php related question but i will be showing a little javascript to get my point across. Basically i have a php form that has a variable that holds an array of email addresses. My problem is I have a link thats calls a javascript function to open a php page in a popup window. My problem is how do i go about posting the php variable containing the emails to the new php popup page if the link is a javascript link? I need it to be post because as passing it through a url wont work due to character limit. Any help would be greatly appreciated and if this post is in the wrong forum i do apologise. for example $test = '<a href onClick="myPopup">Open new form</a>'; then that calls the function myPopup which opens for example test.php. So now i need to pass $emails to this new form via POST from the previous form holding the href link? Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 10, 2008 Share Posted November 10, 2008 Well, you're not providing all the necessary informatioin so I'll give it a shot. How does the array of email addresses exist in the original page? Is it converted to a JavaScript array? If it is you can reference javascript values on the parent page from the popup using the parent.opener.variable_name If it's in a form, as your post suggests, "how" is it in a form? Do you have multiple form fields for each email address? You could again use parent.opener to iterrate through all of those form fields. There are a lot of other possibilities based upon your actual implementation. If you have something different please post some specifics. Quote Link to comment Share on other sites More sharing options...
ghqwerty Posted November 10, 2008 Share Posted November 10, 2008 you could add your $emails into a session and then justuse $_SESSION['emails'] when you need them edit : can you not read my post ???? just do <?php $_SESSION['email'] = $emails; $_SESSION['cc'] = $cc; $_SESSION['bcc'] = $bcc; ?> and then on your popup page to save you having to write $_SESSION['email'] every time you need it just run $emails = $_SESSION['email'] ; $cc = $_SESSION['cc']; $bcc = $_SESSION['bcc']; Quote Link to comment Share on other sites More sharing options...
jake2891 Posted November 10, 2008 Author Share Posted November 10, 2008 Basically $emails variable gets its value from calling a php function that pulls email addresses from a database and apends each email in an array by a ; the other popup form is a form containing a message textarea and a cc and bcc input fields. the form also has a send button which sends the email. the to field gets its value from the posting of the array of emails that i need to somehow get to that new popup form. Quote Link to comment Share on other sites More sharing options...
jake2891 Posted November 10, 2008 Author Share Posted November 10, 2008 yeah i Basically $emails variable gets its value from calling a php function that pulls email addresses from a database and apends each email in an array by a ; the other popup form is a form containing a message textarea and a cc and bcc input fields. the form also has a send button which sends the email. the to field gets its value from the posting of the array of emails that i need to somehow get to that new popup form. was thinking thats a possibility but i dont think its the best solution i was hoping to find a proper way of doing it thanks though Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 10, 2008 Share Posted November 10, 2008 Well, you could have the popup page make the call to the db to get the email addresses. Not sure what criteria you may have on the main page to do that now though (although you could set those values via SESSION also). But, I think ghqwerty is right on. Sessions would be the way to go. You should build the solution so the user doesn't have to have JS enabled anyway. The only reason to use JS for a popup would be to configure the popup window. But there's no reason you couldn't use a traditional link with the target attribute. With sessions you take all the need for JS out of the problem. Quote Link to comment Share on other sites More sharing options...
jake2891 Posted November 10, 2008 Author Share Posted November 10, 2008 Okay thanks for all your input and help guys. I will go with the session solution 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.