Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Beatnik (493)

  (email not shown publicly)

A 29 year old belgian who likes Mountain Dew, Girl Scout Cookies, Tim Hortons French Vanilla Flavoured Cappucinno, Belgian beer, Belgian chocolate, Belgian women, Magners Cider, chocolate chipped cookies and Perl. Likes snowboarding, snorkling, sailing and silence. Bach can really cheer him up! He still misses his dog.

Project Daddy of Spine [], a mod_perl based CMS.

In his superhero time (8.30 AM to 5.30 PM), he works on world peace.

Journal of Beatnik (493)

Tuesday December 23, 2003
06:46 PM

Javascript trick

[ #16481 ]
Here's one that has been puzzling me for quite some time. It took me a while to find an easy and working example online so I'm posting this in case someone else needs this as well.

It concerns a parent and a child window. The parent window is your main browser window, the child window is a basic pop-up (the good kind). The example below is used in a situation where the space on the page is too small for all form fields. I moved the more advanced fields to the advanced pop-up but I want to make sure all fields are saved when pressing the save button on the parent window.

This is the main form. It contains a hidden field for each of the fields in the pop-up window. Through Javascript, you read and set those values.

<form action="" method="post">
<input type="button" value="Advanced" onclick="'advanced.html','AdvancedWindow','width=600,height=200,scro llbars=yes'); return false;">
<input type="hidden" name="extrafield" value="foo">
<input type="submit">

The following bit is the HTML for the child window (in this case in advanced.html)

<script type="text/javascript">
function storeValues(newform) {
self.opener.document.forms[0].extrafield.value = newform.extrafield.value;

function loadValues() {
var newform = document.forms[0];
newform.extrafield.value = self.opener.document.forms[0].extrafield.value;
<body onload="loadValues();">
<form name="newform">
<input type="button" value="Save" onclick="storeValues(document.newform)">
Field : <input name="extrafield" type="text">

Hope this helps anyone :D
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.