JavaScript Variables - newbie

wxdqz

New Member
Hi,

I'm rather new to JavaScript and have a question. I am creating a conditional value list. In the script below I have the the bracketed value for the arrays written as text (such as "Smallville_Ep_1" for the first array). In the html form the options match correctly, but the conditinal list does not change as new items are selected. If I change the code to something like "aLBValues[1] = new Array" it seems to work. So, I guess my question is do these values have to be numbers? I apologize if this sounds confusing, I'm not familiar with JavaScript. The script I'm working with is an example I have modified. If this sounds confusing I can post the entire html doc, but the script in the header is posted below.
thanks!
Nate




<SCRIPT langauge=javascript>

var aLBValues = new Array() ;

aLBValues[Smallville_Ep_1] = new Array("FOG2", "FOG3", "XRAY2", "XRAY2", "BYRON2", "BYRON2", "THROW4", "COPTER1", "COPTER2", "RIG1", "SPEED4", "SPEED6", "SPEED6", "SPEED5", "");

aLBValues[Gabrielle] = new Array("SIGN1", "THROW3", "");

aLBValues[Overhead] = new Array("");

aLBValues[System_Admin] = new Array("");

aLBValues[Smallville_Ep_2] = new Array("THROW1", "THROW3", "THROW4", "COPTER1", "COPTER3", "COPTER3", "TILT1", "SPEED2", "SPEED4", "SPEED3", "SPEED5", "BYRON3", "");

aLBValues[Smallville_Ep_3] = new Array("FOG1", "BYRON2", "THROW1", "THROW5", "THROW5", "SPEED1", "TILT1", "SPEED2", "RIG1", "BYRON4", "");

aLBValues[Smallville_Ep_4] = new Array("SPEED1", "COPTER3", "SPEED3", "BYRON4", "");

aLBValues[Devil's_Throat] = new Array("", "FOG1", "FOG2", "FOG3", "FOG4", "FOG4", "COPTER1", "COPTER3", "RIG1", "WELL1", "WELL1", "BYRON3", "BYRON3", "BYRON4", "");

aLBValues[Smallville_Ep_5] = new Array("");



function addLBElement(oLB, value, text)
{
var oNewOption = new Option(text) ;
oNewOption.value = value;

oLB.options[oLB.options.length] = oNewOption ;
}

function updateLB()
{
var oLBSource = document.the_form.timeCardID::t_show ;
var oLBDest = document.the_form.timeCardID::t_shotName ;
var nSelId = oLBSource[oLBSource.selectedIndex].value ;

oLBDest.length = 0 ; // Clear the LB

for(nLoop = 0; nLoop < aLBValues[nSelId].length; nLoop++)
{
addLBElement(oLBDest, nLoop, aLBValues[nSelId][nLoop]) ;
}
}
function onLoad()
{
updateLB() ;
}
</SCRIPT>
 
Back
Top