View Full Version : Can anyone help me to solve the Javascript error???
NinjaTurtle
04-28-2003, 02:38 AM
Please feel free to go here:
http://www.lhhb.com/intranet/SDIC/test/testing.asp
TQ.
joh6nn
04-28-2003, 06:18 AM
um. generally, you post what the problem you're having is. it's harder for us to help if we don't know what's wrong.
NinjaTurtle
04-28-2003, 07:09 AM
emmm... just need your help me to debug the error, bcos i get erro when i just go in to the page....
cheesebagpipe
04-28-2003, 07:30 AM
Ninja...your code is a bit too thick to pick through this late (11:20PM here), but, what's up here?
var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()
group[0][0] =new Option('-- Select a State -- ','')
group[1][0]= new Option('Jakarta','JKT')
group[2][0]= new Option('Johor','JH')
group[2][1]= new Option('Kedah','KD')
group[2][2]= new Option('Kelantan','KLT')
You're creating 'groups' number of arrays, and then simply hardcoding in the indices. It's caused you to only set one nested array element in group[1] ([0]) - so, down below, when you use group[i].length as a limit, you don't get past the one element. So you get an error when you refer to secondGroup[1][1]. Here's a sample of what's happening:
// generate Territory data.
var secondGroups=document.childform.State.options.length
var secondGroup=new Array(groups)
for (i=0; i<groups; i++){
secondGroup[i]=new Array (group[i].length)
for (j=0;j<group[i].length;j++){alert('secondGroup['+i+']['+j+']')
secondGroup[i][j]=new Array()
}
}
This is pretty messy - a 'group' here and a 'groups' there, no wonder you're confused. I'd say needs some major work but, hope that helps anyway.
NinjaTurtle
04-28-2003, 08:07 AM
dear cheesebagpipe,
i know a bit messy but the code is i download from some a website.
i debug the page for 1 week already but still cannot get wat problem actually caused error... can u help me in more details???
tamienne
04-29-2003, 02:49 PM
NinjaTurtle,
One thing i see right off it that when you create a new option you pass in text, value, defaultSelected, selected. defaultSelected & selected are boolean values. You have strings.
cheesebagpipe's response is the issue...
pretty much in your 'secondGroup for loop' you're initializing your secondGroup array as this...
secondGroup[0] is an array with length 1
secondGroup[1] is an array with length 1
secondGroup[2] is an array with length 14
etc...
now you try to set secondGroup[1][1][0], well it can't reference secondGroup[1][1] since the max is secondGroup[1][0]
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.