Page 1 of 1

[SOLVED] navigation from drop down selection boxes fails

Posted: Fri Feb 18, 2005 11:50 am
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:

Posted: Fri Feb 18, 2005 1:13 pm
by sametch
Now sorted, please ignore, the problem was with the button caling the script.