Open in a new window with javascript

Hello,

I have an asp page to search for data. I like to open it in a new window while retain the search values. And I also can resize the window as well as set its attributes like
height, width,etc.

I created a js function like this:

function posttopopup(formname, windowname)
{
if (! window.focus)return true;
window.open(‘’, windowname);
formname.target=windowname;
return true;
}

on my asp search page:

<form method=“post” action=search.asp" onSubmit=“posttopopup(this, ‘popupwindow’)”>

<input type=“button” name=“Submit1” value=“Search” onclick=“if (isDate()) document.Search.submit();”>

I keep getting errors like “document.search has no value…”

What did I do wrong?

Thanks.

The simple solution is to make the button a submit button, so that it automatically submits the form without you needing to make any special calls.

If the function call results in a value that you don’t like (returning false for not a date, for example), you can return that value to the onclick event to prevent the submit button from submitting the form.

A simple way is this:


<input type="submit" name="Submit1" value="Search" onclick="if (isDate() === false) { return false; }">

You can make it even simpler like this:


<input type="submit" name="Submit1" value="Search" onclick="return isDate();">