trm0002
08-27-2012, 08:22 PM
I've found this javascript that does exactly what I was looking for. By choosing from two categories an URL is generated, that takes the user to a specific site based on what parameters the user chooses in the drop down menu. It is crucial that these links open in a new window or in a new tab - just NOT in the same tab (_self). Please help! I've posted the script below (it's working) and tried all sorts of things to make the links open in a new tab/window... no succes yet... Does anyone know what to do?
<!DOCTYPE html>
<html>
<body>
<!-- DROP-DOWN NAVIGATION MENU - III -->
<!-- This goes in the HEAD of the html file -->
<script language="JavaScript" type="text/javascript">
<!-- Copyright 2001, Sandeep Gangadharan -->
<!-- For more free scripts go to http://sivamdesign.com/scripts/ -->
<!--
function tothePage() { // modify the script below to match your needs
if (document.drop.choice1.selectedIndex == 0 || document.drop.choice2.selectedIndex == 0) { return; }
if (document.drop.choice1.selectedIndex == 1 && document.drop.choice2.selectedIndex == 1) { window.location.href="Script1.html"; }
if (document.drop.choice1.selectedIndex == 1 && document.drop.choice2.selectedIndex == 2) { window.location.href="Script2.html"; }
if (document.drop.choice1.selectedIndex == 1 && document.drop.choice2.selectedIndex == 3) { window.location.href="Script3.html"; }
if (document.drop.choice1.selectedIndex == 2 && document.drop.choice2.selectedIndex == 1) { window.location.href="Program1.html"; }
if (document.drop.choice1.selectedIndex == 2 && document.drop.choice2.selectedIndex == 2) { window.location.href="Program2.html"; }
if (document.drop.choice1.selectedIndex == 2 && document.drop.choice2.selectedIndex == 3) { window.location.href="Program3.html"; }
}
// -->
</script>
<!-- This goes in the BODY of the html file -->
<form name="drop">
<select name="choice1"> // you can add as many items in this drop down list as you want
<option selected value=0>Choose Product ...</option>
<option value=1>Free Script</option>
<option value=2>Free Program</option>
</select>
<select name="choice2"> // you can add as many items in this drop down list as you want
<option selected value=0>Choose Item ...</option>
<option value=1># 1</option>
<option value=2># 2</option>
<option value=3># 3</option>
</select>
<input type="button" value="Go!" onClick="tothePage()" />
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<!-- DROP-DOWN NAVIGATION MENU - III -->
<!-- This goes in the HEAD of the html file -->
<script language="JavaScript" type="text/javascript">
<!-- Copyright 2001, Sandeep Gangadharan -->
<!-- For more free scripts go to http://sivamdesign.com/scripts/ -->
<!--
function tothePage() { // modify the script below to match your needs
if (document.drop.choice1.selectedIndex == 0 || document.drop.choice2.selectedIndex == 0) { return; }
if (document.drop.choice1.selectedIndex == 1 && document.drop.choice2.selectedIndex == 1) { window.location.href="Script1.html"; }
if (document.drop.choice1.selectedIndex == 1 && document.drop.choice2.selectedIndex == 2) { window.location.href="Script2.html"; }
if (document.drop.choice1.selectedIndex == 1 && document.drop.choice2.selectedIndex == 3) { window.location.href="Script3.html"; }
if (document.drop.choice1.selectedIndex == 2 && document.drop.choice2.selectedIndex == 1) { window.location.href="Program1.html"; }
if (document.drop.choice1.selectedIndex == 2 && document.drop.choice2.selectedIndex == 2) { window.location.href="Program2.html"; }
if (document.drop.choice1.selectedIndex == 2 && document.drop.choice2.selectedIndex == 3) { window.location.href="Program3.html"; }
}
// -->
</script>
<!-- This goes in the BODY of the html file -->
<form name="drop">
<select name="choice1"> // you can add as many items in this drop down list as you want
<option selected value=0>Choose Product ...</option>
<option value=1>Free Script</option>
<option value=2>Free Program</option>
</select>
<select name="choice2"> // you can add as many items in this drop down list as you want
<option selected value=0>Choose Item ...</option>
<option value=1># 1</option>
<option value=2># 2</option>
<option value=3># 3</option>
</select>
<input type="button" value="Go!" onClick="tothePage()" />
</form>
</body>
</html>