Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change form values in popup window

Status
Not open for further replies.

RobJDB

Programmer
May 13, 2002
44
GB
Is it possible to open a popup window that has a form in it, and then, from the parent window, change the values of the form fields in the popup and then submit it and close it?

I know about passing values and picking them up in the popup, but the trouble is I cannot edit the code of the popup at all in this case. All I can do is open it and hopefully write to its form.

I'm guessing it might be something like

popupname.form1.textbox.value = 'myname';

but I can't find anything that works yet. Any ideas?
 
sure: suppose you name your popup window "popup" and its form "popform", then from your parent you can access popup's form elements using:

popup.popform.elementname

show the code you're using if this doesn't help.
 
actually, you may need to use this syntax:

popup.document.popform.elementname
 
Try this :

var mWin = window.open ("foo.htm");
mWin.document.form.element.value = "Foo";
mWin.focus (); Regards

David Byng

spider.gif


davidbyng@hotmail.com
 
I'm getting 'document.form1.nm is null or not an object' when I use:

<script language=&quot;JavaScript&quot;>
<!--
function formPop() {

var mWin = window.open (&quot;popup.htm&quot;);
mWin.document.form1.nm.value = &quot;test&quot;;
mWin.focus ();

}
//-->
</script>

Sorry to go on about this! Any more help...?
 
Here you go :

------------------------------
First Page
------------------------------

Code:
<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
<!--
    function formPop (url, form, elmt, vlu) {
        var mWin = window.open (url);
        mWin.document[form][elmt].value = vlu;
        mWin.focus ();
    }
//-->
</script>

<a href=&quot;javascript:formPop ('popup.htm', 'form1', 'nm', 'test');&quot;>Open Window</a>

------------------------------
Popup Page
------------------------------

Code:
<form name=&quot;form1&quot;>
  <input type=&quot;text&quot; name=&quot;nm&quot;><br />
  <input type=&quot;submit&quot; value=&quot;Go&quot;>
</form>
Regards

David Byng

spider.gif


davidbyng@hotmail.com
 
Dave, I really appreciate that, but I just got

'document[...]' is null or not an object

- same error again basically.

I'm using IE6 with W2K, so nothing old or odd there. I don't know what's going on. Don't worry about it though - you've done enough! If I crack it I'll let you know.

Thanks,

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top