...

View Full Version : Drop down menu Problem Help!



Feckie
05-13-2009, 10:59 AM
Why does this not send page to the menu frame "menu"
at the moment it sends it to new window.

Help Please



<html>

<head>
<title>Hello!</title>
<script type="text/javascript">


//1) CUSTOMIZE TEXT DESCRIPTIONS FOR LINKS ABOVE
var thetext1=new Array()
thetext1[0]="Select Year"
thetext1[1]="All Films"
thetext1[2]="2007 Films"
thetext1[3]="2008 Films."
thetext1[4]="2009 Films"

/// You may define additional text arrays if you have multiple drop downs:
var thetext2=new Array()
thetext2[0]="All Years."
thetext2[1]="2007."
thetext2[2]="2008."
thetext2[3]="2009."

// Now, see 2) below for final customization step

function displaydesc(which, descriptionarray, container){
if (document.getElementById)
document.getElementById(container).innerHTML=descriptionarray[which.selectedIndex]
}

function jumptolink(what){
var selectedopt=what.options[what.selectedIndex]
if (document.getElementById && selectedopt.getAttribute("target")=="menu")
window.open(selectedopt.value)
else
window.location=selectedopt.value
}

//2) Call function displaydesc() for each drop down menu you have on the page
// This function displays the initial description for the selected menu item
// displaydesc(name of select menu, name of corresponding text array, ID of SPAN container tag):
// Important: Remove the calls not in use (ie: 2nd line below if there's only 1 menu on your page)

displaydesc(document.form1.select1, thetext1, 'textcontainer1')
displaydesc(document.form2.select2, thetext2, 'textcontainer2')

</script>


</head>

<body>
<form name="form1">
<select name="select1" size="1" style="background-color:#FFFFD7" onChange="displaydesc(document.form1.select1, thetext1, 'textcontainer1')">
<option selected value="">Select Year</option>
<option value="menu.php" target="menu">All Years </option>
<option value="2007.php" target="menu">2007</option>
<option value="2008.php" target="menu">2008</option>
<option value="2009.php" target="menu">2009</option>
</select>
<input type="button" value="Go"
onClick="jumptolink(document.form1.select1)"><br>
<span id="textcontainer1" align="left" style="font:italic 13px Arial">
</span>
</form>

</body>

</html>

mic2100
05-13-2009, 01:38 PM
hi,

if you comment out ur code like this


function jumptolink(what){
var selectedopt=what.options[what.selectedIndex]
//if (document.getElementById && selectedopt.getAttribute("target")=="menu")
//window.open(selectedopt.value)
//else
window.location=selectedopt.value
}


it forces the code to use the window.location. So it wud appear that when ever u run ur code it is using


window.open(selectedopt.value);

instead of


window.location=selectedopt.value;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum