[SOLVED] navigation from drop down selection boxes fails

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
sametch
Forum Newbie
Posts: 9
Joined: Mon Dec 20, 2004 4:53 am

[SOLVED] navigation from drop down selection boxes fails

Post by sametch »

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!

Code: Select all

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

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

feyd | :roll:
sametch
Forum Newbie
Posts: 9
Joined: Mon Dec 20, 2004 4:53 am

Post by sametch »

Now sorted, please ignore, the problem was with the button caling the script.
Post Reply