[thelist] JS Form Submit and Popup window

jeff jeff at members.evolt.org
Wed Jan 3 02:52:08 CST 2001


: From: CDitty
: Can someone look at this code and see what
: is wrong?  I want to do a few form checking
: then if everything is ok, open a new window
: with the new page.   Right now, it does the error
: checking and if everything is ok, it opens 2 windows.
: One with nothing and the other has my new page on it.

i don't immediately see why it's opening two windows, although i suspect it
has to do with the fact that you're calling the openWin() function
separately.  if you want to do form validation as well, you might as well
just move the contents of the openWin() function and it's necessary
arguments to the query_validator() function.

function query_validator(form, wName, wWidth, wHeight, wResize)
  if (form.emailaddr.value == "")
    alert('Email address required to play.');
    return false;
  features = 'location=1,scrollbars,status,resizable='
                 + ((wResize) ? 1 : 0)
                 + ((wWidth) ? ',width=' + wWidth : '')
                 + ((wHeight) ? ',height=' + wHeight : '');
  popWin = window.open('',wName,features);
  if(popWin.focus) { popWin.focus(); }
  return true;

then change your call to it like this:

onSubmit="return query_validator(this, this.target, 800, 600, true)">

does my example open two windows?



mailto:jeff at members.evolt.org

More information about the thelist mailing list