I want to be able to select from multiple sets of data using a select dropdown. All my code looks for one variable to pull the data from the selected array. I have defined my arrays and when I set my variable to use the data from an array it works throughout my code. When I try to change the array in the variable with a function instead of selecting the array the variable is set to the name of the array.
HTML
<select id="panelType" onchange="selectPanel(value)">
<option value="S5">S5</option>
<option value="X6">X6</option>
<option value="F4">F4</option>
</select>
Javascript
var S5 = [.5, .5, 96, 96, 16.3, 1.05, 0, .5, 3, 0, 0];
var X6 = [.5, .5, 72, 72, 21.2, 1.05, 1, 4, 40, 1, 18.1];
var F4 = [.5, 1, 104, 208, 28.4, 2.05, 1, 2, 17.6, 1, 9];
var pData = X6;
alert(pData[3]);
function selectPanel(pType)
{
pData = pType;
alert(pData[2]);
}
The first alert returns 208, but the alert in the function returns undefined. If I were to change it to alert(pData); it would return S5 if I selected the first option.