|
| Index | Recent Threads | Unanswered Threads | Who's Online | User List | Help |
|
|
| No member browsing this thread |
|
Thread Status: Active Total posts in this thread: 4
|
|
| Author |
|
|
Stranger Joined: Aug 5, 2005 Post Count: 3 Status: Offline |
Hello, I am looking for some answers as far as running javascript in firefox. I am trying to run a dynamic drop down menu for a form I am creating. It runs fine in IE however it does not run correctly in firefox... heres the javascript code var arrClasses, arrALH, arrCOM, arrECO arrALH = ['1111014', '2263041', '2451041'] arrCOM = ['1053041', '1211041'] arrECO = ['1013041'] arrClasses = [arrALH, arrCOM, arrECO] function handleChange(newDisplay) { var deptSelect, numSelect, numEntries, i deptSelect = document.forms.shortForm.primary numSelect = document.forms.shortForm.secondary for(i = numSelect.length; i >0; i--) { numSelect.options[i-1] = null } numSelect.options[0] = new Option ("--Select--", 0) if(newDisplay>=0) { numEntries = arrClasses[newDisplay].length for(i =1; i<= numEntries; i++) { numSelect.options = new Option((arrClasses[newDisplay]) [i-1], (arrClasses[i-1])) } } numSelect.selectedIndex = 0 } and the corresponding html <select name="primary" onChange="handleChange(this[this.selectedIndex].value)"> <option value = "-1" selected>--Select--</option> <option value = "0">ALH</option> <option value = "1">COM</option> <option value = "2">ECO</option> <option value = "3">EDU</option> <option value = "4">ENG</option> <option value = "5">HIS</option> <option value = "6">MAT</option> <option value = "7">NUR</option> <option value = "8">PSY</option> <option value = "9">SPE</option> <option value = "10">CTD</option> </select> <select name="secondary"> <option value ="-1"> -- Select --</option> <option></option> <option></option> </select> now in IE i recieve results that look like this ALH102201 and in firefox I recieve ALHundefined any ideas???? thanks in advance ---------------------------------------- [Edit 1 times, last edit by tawanda at Aug 5, 2005 11:54:49 AM] |
||
|
|
Advanced Member UK Joined: Dec 29, 2004 Post Count: 1662 Status: Offline |
Have you checked FireFox's Javascript Console? It would be useful if you could put your html and javascript on to a server in a working state and link to them. That way it would be easier for us to debug your code. ![]() Tim ---------------------------------------- Pavonis Mons | Listen of the week: "Residue of Desire" by Acumen |
||
|
|
Stranger Joined: Aug 5, 2005 Post Count: 3 Status: Offline |
I am working on getting this code put onto a server... in the meantime... I ran the javascript console in firefox and I recieve one error Error: arrClasses has no properties Source File: http://localhost/paypal/dynamic.js so.. here is the code again with some changes var arrClasses = new Array (3) arrALH = new Array(3) arrCOM = new Array(2) arrECO = new Array(1) arrALH = ['1111014', '2263041', '2451041'] arrCOM = ['1053041', '1211041'] arrECO = ['1013041'] arrClasses = [arrALH, arrCOM, arrECO] function handleChange(newDisplay){ var deptSelect, numSelect, numEntries, i deptSelect = document.forms.shortForm.primary numSelect = document.forms.shortForm.secondary //alert(typeof(numSelect)) for(i = numSelect.length; i >0; i--) { numSelect.options[i-1] = null } numSelect.options[0] = new Option ("--Select--", 0) if(newDisplay>=0) { numEntries = arrClasses[newDisplay].length for(i =1; i<= numEntries; i++) { numSelect.options = new Option((arrClasses[newDisplay])[i-1], (arrClasses[i-1])) } } numSelect.selectedIndex = 0 } so.... not sure why arrClasses has no properties?? any ideas?? thanks in advance |
||
|
|
Stranger Joined: Aug 5, 2005 Post Count: 3 Status: Offline |
Just incase anyone runs into the same problem... I changed the arrays to look like var arrClasses = new Array (11) arrClasses[0] = new Array(4)//var arrALH = new Array(3) arrClasses[0][0] = "ALH" arrClasses[0][1] = "1111014" arrClasses[0][2] = "2263041" arrClasses[0][3] = "2451041" arrClasses[1] = new Array(3)//var arrCOM = new Array(2) arrClasses[1][0] = "COM" arrClasses[1][1] = "1053041" arrClasses[1][2] = "1211041" arrClasses[2] = new Array(2)//var arrECO = new Array(1) arrClasses[2][0] = "ECO" arrClasses[2][1] = "1013041" and now it works fine... thanks for all the help |
||
|
|
|
|
|
Current timezone is GMT Sep 5, 2010 10:20:02 PM |