Results 1 to 5 of 5

Thread: hyperlink option in drop-down form

  1. #1
    Join Date
    May 2007
    Posts
    35
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default hyperlink option in drop-down form

    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>

  2. #2
    Join Date
    Nov 2006
    Posts
    236
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    did you make the page an first. I see no reason why you idea wouldn't work.

  3. #3
    Join Date
    May 2007
    Posts
    35
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default thanks

    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>

  4. #4
    Join Date
    Feb 2007
    Location
    England
    Posts
    254
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default

    Try something like this

    Code:
    <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.

  5. #5
    Join Date
    May 2007
    Posts
    35
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    You rock! Thank you.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •