Hello everyone,
I am trying to have an email form which has a "submit" (sends the email off) and a "preview" button (shows you what the email will look like). I have the look of the form done. My problem is this:
I want the preview button to load the information into a new browser window, but when you click the "submit" button I don't want the information ("thank you the email has been sent to the following users...") to be put on a new browser window.
I am having a really hard time with this. I think I need to use some Javascript to do this. I don't know very much Javascript, but this is what I have so far and the "submit" button works but the preview does not. The preview will open a new browser window but the $subject, $message, $to fields will not display on that new form.
Here is my attempt.I am just trying to get one field working (addEmail field)Can anyone see what is wrong with it? :
print ("<FORM name='emailPeopleForm'><table>");
print ("<tr>");
print ("<tr>");
print ("<td>To:</td><td>");
print"<input type=\"text\" onBlur=\"assignAddEmail(valid(this))\" size=\"70\" name=\"addEmail\">";
print ("</td></tr>");
print ("<tr>");
print ("<td colspan=2><center>");
$preview='PreviewEmailMessage';
// -------------
print"</form><form name='Form1'>";
print("<INPUT TYPE='HIDDEN' name='addEmail' >"); print ("<INPUT TYPE='SUBMIT' name='submit' value='SendEmailMessage'>");
print"</form><form name='Form2' target='_blank'>";
print("<INPUT TYPE='HIDDEN' name='addEmail' >");
print ("<INPUT TYPE='SUBMIT' name='submit' value='PreviewEmailMessage' >");
print ("</center></tr>");
print ("</table></form>");
All of the about is in my classes.php file within a class "mailer".
This Javascript is in my header file:
function assignAddEmail(field){
document.Form1.addEmail.value= field.value();
document.Form2.addEmail.value= field.value();
}
I am really stuck on this. Please help. Any help is greatly appreciated. Thanks for your time.