SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    linking to webpages using drop down box selection

    I have two drop down boxes on a form with a submit button. I would like to be able to link to different pages depending upon the combination of selections a user makes.

    I have written the following function which is executed from the submit button on click event.

    When I operate it I get the message box, but the browser doesn't redirect. Can anyone help!

    <script type="text/javascript">
    <!--
    function testbutton()
    {
    var searchForm = document.search;
    var linkAddress;

    if (searchForm.region.value == "ALL" && searchForm.specialism.value == "ALL" )
    {
    linkAddress = searchForm.region.value + searchForm.specialism.value + ".html";
    alert("both regions set to all " + linkAddress + "!");
    window.location.href = linkAddress;
    }
    else if (searchForm.region.value == "ALL" && searchForm.specialism.value != "ALL" )
    {
    linkAddress = searchForm.specialism.value + ".html";
    alert("only specialism selected! " + linkAddress);
    window.location.href = linkAddress;
    }
    else if (searchForm.region.value != "ALL" && searchForm.specialism.value == "ALL" )
    {
    linkAddress = searchForm.region.value + ".html";
    alert("only region selected! " + linkAddress);
    window.location.href = linkAddress;
    }
    else
    {
    linkAddress = searchForm.specialism.value + "-" + searchForm.region.value + ".html";
    alert("both selected! " + linkAddress);
    window.location.href = linkAddress;
    }
    }
    // -->
    </script>

  2. #2
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now sorted the problem was with the button activating the script.


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
  •