[thelist] Javascript Help - New Window + Search Function

Joshua Olson joshua at waetech.com
Thu Oct 6 12:24:58 CDT 2005


> -----Original Message-----
> From: Administrative HQ
> Sent: Thursday, October 06, 2005 12:55 PM
> 
> BUT I need the search to open in a new window.
> 
> Trying various coding to open a window, I've succeeded
> to get a blank window to come up, but it's blank! I
> can't get the search results to appear in the new
> window. I've found no help on the web for getting
> onclick to do two things at once. The usual way of
> giving the new window a URL doesn't seem right because
> the "submit" button calls a function.

David,

Here's what you need to look at:

1.  Add the target attribute to the form.
2.  Move the function to the form's onsubmit handler:

<form target="_blank" 
  method="post" 
  action="" 
  onsubmit="return startSearch(this);">

function startSearch(form)
{
  // Your code goes here
  //..
  // Of course, since you are passing in a reference
  // to form you should be able to simplify your
  // code somewhat.

  form.action = finalSearchString;
  return true;
}

If you want the popup window to be "custom", then change things to the
following:

function startSearch(form)
{
  // Your code goes here
  //..

  var win = window.open(finalSearchString, '_blank', 'width=....');
  return false;
}

This code is untested, but should get you going in the right direction.

<><><><><><><><><><>
Joshua L. Olson
WAE Tech Inc.
http://www.waetech.com/
Phone: 706.210.0168 
Fax: 413.812.4864

Monitor bandwidth usage on IIS6 in real-time:
http://www.waetech.com/services/iisbm/




More information about the thelist mailing list