PDA

View Full Version : hyperlink option in drop-down form



jianxin9
05-15-2007, 02:07 PM
Hi everyone,
Is there a javascript code that will allow for a hyperlink option in a drop-down form? I have the following code. It works great--it gives the option to search different databases. However, I would like the last option in the search form drop-down to be a hyperlink where people can click on it and be taken to another page with a full database list. Is there any way to do this? I would appreciate any help. Thanks.



<script language="JavaScript">
<!--

//
// Script by Jari Aarniala
//
// This script makes it easy to choose with which search engine
// you`d like to search the net. You may use this if you keep this
// text here...
//

function startSearch(){
searchString = document.searchForm.searchText.value;
if(searchString != ""){
searchEngine = document.searchForm.whichEngine.selectedIndex + 1;
finalSearchString = "";

if(searchEngine == 1){
finalSearchString = "http://ezproxy.twu.edu:2048/login?url=http://search.ebscohost.com/login.aspx?direct=true&amp;db=aph&bquery=" + searchString;
}
if(searchEngine == 2){
finalSearchString = "http://ezproxy.twu.edu:2048/login?url=http://search.ebscohost.com/login.aspx?direct=true&amp;db=rzh&bquery=" + searchString;
}
if(searchEngine == 3){
finalSearchString = "http://ezproxy.twu.edu:2048/login?url=http://search.ebscohost.com/login.aspx?direct=true&amp;db=mnh&bquery=" + searchString;
}
if(searchEngine == 4){
finalSearchString = "http://ezproxy.twu.edu:2048/login?url=http://search.ebscohost.com/login.aspx?direct=true&amp;db=psyh&bquery=" + searchString;
}
location.href = finalSearchString;
}
}


// -->
</script>

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

<form name="searchForm">
<input type="text" size="27" name="searchText" value=' type in a keyword or "phrase"' class="cleardefault" />

<select style="background: dddddd" name="whichEngine" >

<option selected>Academic Search Premier</option>
<option>CINAHL Plus with Full Text</option>
<option>Medline with Full Text</option>
<option>PsycINFO</option>
<option value"">Please click here to be taken to database list</option>
</select><input type="button" value="Search" onClick="startSearch()">

</select>

riptide
05-15-2007, 05:31 PM
did you make the page an first. I see no reason why you idea wouldn't work.

jianxin9
05-15-2007, 05:39 PM
Thanks for the response. I did test it this way, but nothing happens when I click on that option.

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

<form name="searchForm">

<input type="text" size="27" name="searchText" value=' type in a keyword or "phrase"' class="cleardefault" />

<select style="background: dddddd" name="whichEngine" >

<option selected>Academic Search Premier</option>
<option>CINAHL Plus with Full Text</option>
<option>Medline with Full Text</option>
<option>PsycINFO</option>
<option value="SOME URL">Please click here to be
taken to database list</option>
</select>

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

</select>

Bob90
05-15-2007, 06:49 PM
Try something like this



<select onchange="tryLink(this)">
<option>1</option>
<option>2</option>
<option value="http://www.gohere.com/">Link </option>
</select>

<script>
function tryLink(obj)
{
if(obj.selectedIndex === 2)
{document.location.href = obj.options[obj.selectedIndex].value}
}
</script>


remember index starts at zero, so 2 is actually the third one in the list.
:)

jianxin9
05-15-2007, 07:13 PM
You rock! Thank you.