I am trying to use the below code on a intranet site.
Works fine....I am trying to have certain links open in a new window. Any Ideas?
<form name="dynamiccombo">
<p><select name="stage2" size="1" onChange="displaysub()">
<option value="#">This is a place Holder text</option>
<option value="#">This is a Place Holder text</option>
<option value="#">This is a Place Holder text</option>
<option value="#">This is a Place Holder text</option>
</select> <input type="button" name="test" value="Go!" onClick="gothere()">
</p>
</form>
<script>
<!--
//2-level combo box script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use
//STEP 1 of 2: DEFINE the main category links below
//EXTEND array as needed following the laid out structure
//BE sure to preserve the first line, as it's used to display main title
var category=new Array()
category[0]=new Option("SELECT A CATEGORY ", "") //THIS LINE RESERVED TO CONTAIN COMBO TITLE
category[1]=new Option("Departments", "combo1")
category[2]=new Option("Search Tools", "combo2")
category[3]=new Option("Intranet Tools", "combo3")
category[4]=new Option("Intranet Applications", "combo4")
//STEP 2 of 2: DEFINE the sub category links below
//EXTEND array as needed following the laid out structure
//BE sure to preserve the LAST line, as it's used to display submain title
var combo1=new Array()
combo1[0]=new Option("Accounting","http://intranet.nat.mdausa.org/intra1/Departments/Accounting/accounting.asp")
combo1[1]=new Option("Information Technology","http://intranet.nat.mdausa.org/intra1/Departments/IT/it.asp")
combo1[2]=new Option("Program Development","http://intranet.nat.mdausa.org/intra1/Departments/ProgramDev/programdev.asp")
combo1[3]=new Option("Purchasing","http://intranet.nat.mdausa.org/intra1/Departments/Purchasing/purchasing.asp")
combo1[4]=new Option("TV Production","http://intranet.nat.mdausa.org/intra1/Departments/TV/tv.asp")
combo1[5]=new Option("BACK TO CATEGORIES","") //THIS LINE RESERVED TO CONTAIN COMBO SUBTITLE
var combo2=new Array()
combo2[0]=new Option("MDA Forms","http://intranet.nat.mdausa.org/intra1/forms.asp")
combo2[1]=new Option("MDA Memo's","http://intranet.nat.mdausa.org/intra1/memo.asp")
combo2[2]=new Option("Site Search","http://intranet.nat.mdausa.org/intra1/Search/Search Form.htm")
combo2[3]=new Option("BACK TO CATEGORIES","") //THIS LINE RESERVED TO CONTAIN COMBO SUBTITLE
var combo3=new Array()
combo3[0]=new Option("National Contacts","http://intranet.nat.mdausa.org/intra1/contacts.asp")
combo3[1]=new Option("Intranet Comments","mailto:[email protected]?subject=Intranet")
combo3[2]=new Option("Content Submittal","http://10.1.1.151/intra1/Upload/content_submit.asp")
combo3[3]=new Option("BACK TO CATEGORIES","") //THIS LINE RESERVED TO CONTAIN COMBO SUBTITLE
var combo4=new Array()
combo4[0]=new Option("MDAUSA.ORG","http://www.mdausa.org")
combo4[1]=new Option("InfoUSA Lists","http://intranet.nat.mdausa.org/infousa/ident.html")
combo4[2]=new Option("BACK TO CATEGORIES","") //THIS LINE RESERVED TO CONTAIN COMBO SUBTITLE
var curlevel=1
var cacheobj=document.dynamiccombo.stage2
function populate(x){
for (m=cacheobj.options.length-1;m>0;m--)
cacheobj.options[m]=null
selectedarray=eval(x)
for (i=0;i<selectedarray.length;i++)
cacheobj.options[i]=new Option(selectedarray[i].text,selectedarray[i].value)
cacheobj.options[0].selected=true
}
function displaysub(){
if (curlevel==1){
populate(cacheobj.options[cacheobj.selectedIndex].value)
curlevel=2
}
else
gothere()
}
function gothere(){
if (curlevel==2){
if (cacheobj.selectedIndex==cacheobj.options.length-1){
curlevel=1
populate(category)
}
else
location=cacheobj.options[cacheobj.selectedIndex].value
}
}
//SHOW categories by default
populate(category)
//-->
</script>
Works fine....I am trying to have certain links open in a new window. Any Ideas?
<form name="dynamiccombo">
<p><select name="stage2" size="1" onChange="displaysub()">
<option value="#">This is a place Holder text</option>
<option value="#">This is a Place Holder text</option>
<option value="#">This is a Place Holder text</option>
<option value="#">This is a Place Holder text</option>
</select> <input type="button" name="test" value="Go!" onClick="gothere()">
</p>
</form>
<script>
<!--
//2-level combo box script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use
//STEP 1 of 2: DEFINE the main category links below
//EXTEND array as needed following the laid out structure
//BE sure to preserve the first line, as it's used to display main title
var category=new Array()
category[0]=new Option("SELECT A CATEGORY ", "") //THIS LINE RESERVED TO CONTAIN COMBO TITLE
category[1]=new Option("Departments", "combo1")
category[2]=new Option("Search Tools", "combo2")
category[3]=new Option("Intranet Tools", "combo3")
category[4]=new Option("Intranet Applications", "combo4")
//STEP 2 of 2: DEFINE the sub category links below
//EXTEND array as needed following the laid out structure
//BE sure to preserve the LAST line, as it's used to display submain title
var combo1=new Array()
combo1[0]=new Option("Accounting","http://intranet.nat.mdausa.org/intra1/Departments/Accounting/accounting.asp")
combo1[1]=new Option("Information Technology","http://intranet.nat.mdausa.org/intra1/Departments/IT/it.asp")
combo1[2]=new Option("Program Development","http://intranet.nat.mdausa.org/intra1/Departments/ProgramDev/programdev.asp")
combo1[3]=new Option("Purchasing","http://intranet.nat.mdausa.org/intra1/Departments/Purchasing/purchasing.asp")
combo1[4]=new Option("TV Production","http://intranet.nat.mdausa.org/intra1/Departments/TV/tv.asp")
combo1[5]=new Option("BACK TO CATEGORIES","") //THIS LINE RESERVED TO CONTAIN COMBO SUBTITLE
var combo2=new Array()
combo2[0]=new Option("MDA Forms","http://intranet.nat.mdausa.org/intra1/forms.asp")
combo2[1]=new Option("MDA Memo's","http://intranet.nat.mdausa.org/intra1/memo.asp")
combo2[2]=new Option("Site Search","http://intranet.nat.mdausa.org/intra1/Search/Search Form.htm")
combo2[3]=new Option("BACK TO CATEGORIES","") //THIS LINE RESERVED TO CONTAIN COMBO SUBTITLE
var combo3=new Array()
combo3[0]=new Option("National Contacts","http://intranet.nat.mdausa.org/intra1/contacts.asp")
combo3[1]=new Option("Intranet Comments","mailto:[email protected]?subject=Intranet")
combo3[2]=new Option("Content Submittal","http://10.1.1.151/intra1/Upload/content_submit.asp")
combo3[3]=new Option("BACK TO CATEGORIES","") //THIS LINE RESERVED TO CONTAIN COMBO SUBTITLE
var combo4=new Array()
combo4[0]=new Option("MDAUSA.ORG","http://www.mdausa.org")
combo4[1]=new Option("InfoUSA Lists","http://intranet.nat.mdausa.org/infousa/ident.html")
combo4[2]=new Option("BACK TO CATEGORIES","") //THIS LINE RESERVED TO CONTAIN COMBO SUBTITLE
var curlevel=1
var cacheobj=document.dynamiccombo.stage2
function populate(x){
for (m=cacheobj.options.length-1;m>0;m--)
cacheobj.options[m]=null
selectedarray=eval(x)
for (i=0;i<selectedarray.length;i++)
cacheobj.options[i]=new Option(selectedarray[i].text,selectedarray[i].value)
cacheobj.options[0].selected=true
}
function displaysub(){
if (curlevel==1){
populate(cacheobj.options[cacheobj.selectedIndex].value)
curlevel=2
}
else
gothere()
}
function gothere(){
if (curlevel==2){
if (cacheobj.selectedIndex==cacheobj.options.length-1){
curlevel=1
populate(category)
}
else
location=cacheobj.options[cacheobj.selectedIndex].value
}
}
//SHOW categories by default
populate(category)
//-->
</script>