Solved

Opening form results in new browser window

Posted on 2008-06-19
5
157 Views
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 = "http://search.ebscohost.com/login.aspx?direct=true&bquery=" + searchString + "&db=a9h";
}
if(searchEngine == 2){
finalSearchString = "http://search.ebscohost.com/login.aspx?direct=true&bquery=" + searchString + "&db=lih";
}
if(searchEngine == 3){
finalSearchString = "http://www.jstor.org/action/doBasicSearch?Query=" + searchString + "&x=0&y=0";
}
if(searchEngine == 4){
finalSearchString = "http://search.ebscohost.com/login.aspx?direct=true&bquery=" + searchString + "&db=f5h";
}
if(searchEngine == 5){
finalSearchString = "http://www.springerlink.com/content/?k=" + searchString + "";
}
location.href = finalSearchString;
}
}
 
 
// -->
</script>
 
<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>LISTA</option>
<option>JSTOR</option>
<option>Masterfile Premier</option>
<option>Springerlink</option>
 
 
</select>
 
<input type="button" value="Search" onClick="startSearch()">
 
</select> </form>

Open in new window

0
Comment
Question by:jianxin9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 21826795
This line is your problem:

location.href = finalSearchString;


Change that line to this  two lines:

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


0
 
LVL 22

Accepted Solution

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

with

window.open(finalSearchString, 'searchResult');
searchResult.focus()
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 21828940
My line with the form.target does the same as window.open() but works also with popup blockers.
0
 
LVL 22

Expert Comment

by:neeraj523
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..
0
 
LVL 63

Expert Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

690 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