|
-
Mar 12th, 2002, 08:52 PM
#1
Thread Starter
Fanatic Member
Using array in js file
I have a webpage that has a combo box. I would like to have a user select something out of the combo box and have the onChange event occur. I would like to then have a script run that will read from a text file (server side) and according to what they selected it would file in another combo box. I know with server/client side stuff this gets messy but is it possible to do it this way? If so how, I can do it be hardcoding the values in but have had no luck when trying to access the file. Should put it into a js file? Here is the code:
<script language="JavaScript">
<!--
/*
Double Combo Script Credit
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free JavaScripts here!
*/
var groups=document.frmA192A.cboOffice.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()
group[1][0]=new Option("JavaScript Kit","http://javascriptkit.com")
group[1][1]=new Option("News.com","http://www.news.com")
group[1][2]=new Option("Wired News","http://www.wired.com")
group[2][0]=new Option("CNN","http://www.cnn.com")
group[2][1]=new Option("ABC News","http://www.abcnews.com")
group[3][0]=new Option("Hotbot","http://www.hotbot.com")
group[3][1]=new Option("Infoseek","http://www.infoseek.com")
group[3][2]=new Option("Excite","http://www.excite.com")
group[3][3]=new Option("Lycos","http://www.lycos.com")
var temp=document.frmA192A.cboVendor
function redirect(x){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
temp.options[0].selected=true
}
function go(){
location=temp.options[temp.selectedIndex].value
}
</script>
//-->
and here is the html that ref's it:
<select name="cboOffice" size="1" onChange="redirect(this.options.selectedIndex)">
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|