Jump to content

php & popups


jake2891

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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'];

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.