Opening form results in new browser window

Posted on 2008-06-19
Last Modified: 2010-04-06
I have a form that allows me to search, etc. but I can't figure out how to open the form results in another browser.  I've inserted target="_blank" but this doesn't seem to be working.
<script language="JavaScript">

function startSearch(){

searchString = document.searchForm.searchText.value; 

if(searchString != ""){

searchEngine = document.searchForm.whichEngine.selectedIndex + 1;

finalSearchString = "";

if(searchEngine == 1){

finalSearchString = "" + searchString + "&db=a9h";


if(searchEngine == 2){

finalSearchString = "" + searchString + "&db=lih";


if(searchEngine == 3){

finalSearchString = "" + searchString + "&x=0&y=0";


if(searchEngine == 4){

finalSearchString = "" + searchString + "&db=f5h";


if(searchEngine == 5){

finalSearchString = "" + searchString + "";


location.href = finalSearchString;



// -->


<basefont face="Verdana, Arial, sans-serif">

<form name="searchForm" target="_blank">

<input type="text"  size="17" name="searchText" value="Database Search" onFocus="clearText(this)">

<select style="background: dddddd" name="whichEngine" onchange="tryLink(this)">

<option selected>Academic Search Complete</option>



<option>Masterfile Premier</option>



<input type="button" value="Search" onClick="startSearch()">

</select> </form>

Open in new window

Question by:jianxin9
  • 3
  • 2
LVL 63

Expert Comment

ID: 21826795
This line is your problem:

location.href = finalSearchString;

Change that line to this  two lines:

document.searchForm.action = finalSearchString; = "ResultWindow"

LVL 22

Accepted Solution

neeraj523 earned 500 total points
ID: 21828483
Replace this
location.href = finalSearchString;

with, 'searchResult');
LVL 63

Expert Comment

ID: 21828940
My line with the does the same as but works also with popup blockers.
LVL 22

Expert Comment

ID: 21829049
@Zvonko.. i guess you missed the fact that 'Search' button is not submitting the form, instead it is just calling Javascript function. So changing the action and target attributes will do nothing till form gets submitted.. which is not the case in this situation..
LVL 63

Expert Comment

ID: 21829398
Yes, I missed that form is not submitted at all.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now