View Full Version : submit form in popup window; send form data to opener window: ISSUE

05-01-2006, 09:28 AM
Ok, I have the following form and relevant code in my pop up window:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" dir="ltr">



<link rel="stylesheet" type="text/css" href="contact_reference.css" />

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

<script type="text/javascript">

function sendFormData(form_object)
remoteForm = window.opener.update_submit;

remoteForm.first_name.value = form_object.first_name.value;
remoteForm.last_name.value = form_object.last_name.value;
remoteForm.business_name.value = form_object.business_name.value;
remoteForm.email.value = form_object.email.value;
remoteForm.website.value = form_object.website.value;
remoteForm.phone.value = form_object.phone.value;
remoteForm.street.value = form_object.street.value;
remoteForm.city.value = form_object.city.value;
remoteForm.state.value = form_object.state.value;
remoteForm.zip.value = form_object.zip.value;
remoteForm.country.value = form_object.country.value;




<form name="form4">

<p>First Name: <input type="text" name="first_name" size="25" value="<? echo $the_fn; ?>"></p>
<p>Last Name: <input type="text" name="last_name" size="25" value="<? echo $the_ln; ?>"></p>
<p>Business Name: <input type="text" name="business_name" size="25" value="<? echo $b_name; ?>"></p>
<p>E-mail Address: <input type="text" name="email" size="25" value="<? echo $the_email; ?>"></p>
<p>Website Address: <input type="text" name="website" size="25" value="<? echo $the_website; ?>"></p>
<p>Phone Number: <input type="text" name="phone" size="25" value="<? echo $the_phone; ?>"></p>
<p>Street Address: <input type="text" name="street" size="25" value="<? echo $the_street; ?>"></p>
<p>City: <input type="text" name="city" size="25" value="<? echo $the_city; ?>"></p>
<p>State/Region: <input type="text" name="state" size="20" value="<? echo $the_state; ?>"></p>
<p>Postal Code: <input type="text" name="zip" size="15" value="<? echo $the_zip; ?>"></p>
<p>Country: <input type="text" name="country" size="25" value="<? echo $the_country; ?>"></p>

<p style="text-align:center"><input type="button" value="Update Contact" onClick="sendFormData(window.document.form4);"><input type="reset" value="Reset Form"><input type="button" value="Cancel" onClick="window.close();"></p>




Using the javascript function sendFormData(), I'm trying to assign values to a hidden form in the opener window, submit the form in the opener window, and then close the pop-up window.

Here's the hidden form in the opener window:

<form method="post" name="update_submit" action="<? echo $_SERVER['PHP_SELF']; ?>">

<input type="hidden" name="first_name">
<input type="hidden" name="last_name">
<input type="hidden" name="business_name">
<input type="hidden" name="email">
<input type="hidden" name="website">
<input type="hidden" name="phone">
<input type="hidden" name="street">
<input type="hidden" name="city">
<input type="hidden" name="state">
<input type="hidden" name="zip">
<input type="hidden" name="country">


Anyway, the javascript in my pop-up window is not functioning and nothing happens.

I checked the javascript console, and I get the following error in my pop-up window's code:

Error: remoteForm has no properties
Source File: http://www.mediamogulsweb.com/blah/blah.php
Line: 21

Can anybody see what the problem is here? thanks.

05-01-2006, 09:49 PM
remoteForm = opener.document.update_submit;

fixed it.