PDA

View Full Version : Forms Two actions on one click of submit button


fwr1000
09-09-2006, 11:13 PM
I have set up a form page for a client using the Dreamweaver Forum formmail script. Everything works great, on clicking the "Submit" button the e mail gets sent and the viewer is redirected to the index page. What I would like to add is a pop up window with a "Thank you, your message has been sent". The pop up should appear over the index page to which the viewer has been directed. I would put a "Close window" button on the pop up but ideally, the pop up would close automatically after 5 seconds and the viewer would then be viewing the home page.

All of this should be done on the click of the submit button on the form.

I am NOT a PHP or javaScript guy so would need some pretty basic instructions.

Thanks for any suggestions
Fred

Here is the form HTML and then the js code.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Contact Page for Elder Law Practice of Judith Just, Attorney, PA</title>
<meta name="description" content="Contact Page for the Elder Law Practice of Judith Ann Just, Attorney, PA, Lake Worth, Florida">




<link href="mainCSS.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>

<body>
<table width="770" border="0" align="center" cellpadding="0" cellspacing="0" id="maniTable">
<tr>
<td height="125" colspan="2" id="header">
<h1>Images/header_contact.jpg</h1>
</td>
</tr>
<tr>
<td valign="top" id="sidebar">

For further information on a specific topic, please choose below: </p>
<ul>
About the Practice (index.html)
Estate Planning (estate_planning.html)
Elder Law (elder_law.html)
Probate (probate.html)
Qualifications/Fees (qualifications.html)


Related Links (resources.html)
Contact Us (contact.html)
[/list]


</p>


Images/NAELA_logoB.png



<font color="#990000" face="Arial" size="2">NAELA and AFELA are nationwide and statewide networks of attorneys specializing in Federal and Stateregulations, statutes and publiclaws related to issues surrounding elder adults.</font> </p>
<p align="center">Images/AFELA_logo.png</p>


</p></td>
<td valign="top" id="content">
<h1 align="center">Contact Information </h1>


For questions or to schedule an appointment, please call us at 561-547-0549 or use the form below and we will contact you. </p>
<form name="form1" method="post" action="contact.php">
<input type=hidden name="recipient" value="judithjust01@hotmail.com">
<table width="400" border="0" cellpadding="5" cellspacing="5" id="form_table">
<tr>
<td width="100"><label>First Name:</label></td>
<td><input name="First_Name" type="text" id="First_Name" size="30"></td>
</tr>
<tr>
<td width="100"><label>Last Name:</label>
</td>
<td><input name="Last_Name" type="text" id="Last_Name" size="30"></td>
</tr>
<tr>
<td width="100">Street Address: </td>
<td><input name="Street_Address" type="text" id="Street_Address" size="50"></td>
</tr>
<tr>
<td width="100">City:</td>
<td><input name="City" type="text" id="City" size="30"></td>
</tr>
<tr>
<td><label>State:</label></td>
<td><input name="State" type="text" id="State" size="3"></td>
</tr>
<tr>
<td width="100">ZIP:</td>
<td><input name="Zzip" type="text" id="Zzip" size="10"></td>
</tr>
<tr>
<td width="100"><label>Phone:</label></td>
<td><input name="Phone" type="text" id="Phone" size="12"></td>
</tr>
<tr>
<td width="100"><label>E-Mail:</label></td>
<td><input name="E-Maill" type="text" id="E-Maill" size="45"></td>
</tr>
<tr>
<td width="100">Best Time to Call: </td>
<td valign="middle"><select name="Best_Time_to_Call" id="Best_Time_to_Call">
<option>(Please Choose)</option>
<option>Business Hours</option>
<option>Morning</option>
<option>Afternoon</option>
<option>Evening</option>
</select></td>
</tr>
<tr>
<td width="100" valign="top"><label>Area of Interest: </label></td>
<td><textarea name="Interest" cols="35" rows="10" id="Interest"></textarea></td>
</tr>
<tr>
<td valign="top"></td>
<td><input type="submit" name="Submit" value="Send Inquiry"></td>
</tr>
</table>
</form>
<h3>Thank you for your interest.</h3>


</p>
</td>
</tr>
<tr>
<td height="78" colspan="2" id="footer">

&copy; Judith Ann Just, Attorney, PA All Rights Reserved

Phone-Fax 561.547.0549

Lake Worth, Florida </p>
</td>
</tr>
</table>

</body>
</html>


<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Inquiry from Just-Law Web Site';

// Your email address. This is where the form information will be sent.
$emailadd = 'judithjust01@hotmail.com';

// Where to redirect after form is processed.
$url = 'http://www.just-law.net/index.html';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

davidj
09-11-2006, 08:32 AM
ok

first create your popup window with your desired message and set this up so it triggers on a button or a link

once you have done this let me know and i will explain the next step

fwr1000
09-11-2006, 12:24 PM
Got it. Have page created. Ready for next step.

davidj
09-11-2006, 12:33 PM
ok

where you have...
onClick=MM_openPopup("4","5","3","4",) //<< example only. Not acurate
on your link

replace the onClick= with onLoad and copy the function call to your clipboard

delete the link you created

/////////////////////////////////////
in your mail script add below the line so it looks like this
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
$popup = "onLoad=MM_openPopup('4','5','3','4')";


then in your body tag just add
<body <?php echo $popup;?>

fwr1000
09-11-2006, 12:58 PM
Thanks David, I'll work on this and repost if any problems/questions

Fred