hi.. im using an array to populate my drop down menu.. here is the script im using
in a traditional drop down.. if i wanted one of these items to be formated i could just do
if i wanted to add css formating to certain items within my array can this be done directly within the script? thanks
Code:
<script type="text/javascript">
// an array to hold the contents of all lists
var DataArray = new Array();
DataArray[0] = new Array("C1","EC1 - City, Clerkenwell", "p1");
DataArray[1] = new Array("C1","EC2 - City, Tower", "p2");
DataArray[2] = new Array("C1","EC3 - City, Bank", "p3");
DataArray[3] = new Array("C1","EC4 - City, Holborn", "p4");
DataArray[4] = new Array("C1","WC1 - Bloomsbury", "p5");
DataArray[5] = new Array("C1","WC1 - St Pancras", "p6");
DataArray[6] = new Array("C1","WC2 - Charing Cross", "p7");
DataArray[7] = new Array("C1","WC2 - Covent Garden", "p8");
DataArray[8] = new Array("C1","WC2 - Holborn", "p9");
DataArray[9] = new Array("C1","WC2 - Leicester Square", "p10");
// swap contents of second list
function switchList(List1)
{ var i, k;
var List2 = document.getElementById("SecondList");
var TypeOfValues = List1.options[List1.selectedIndex].value;
//Remove all items in SecondList listbox
//Start removing items at end and work back to front
k = List2.options.length - 1;
for (i = k; i >= 0; i--)
{ List2.options[i] = null;
}
k = 0;
for(i = 0; i < DataArray.length; i++)
{ if (DataArray[i][0] == TypeOfValues)
{ List2.options[k] = new Option(DataArray[i][1], DataArray[i][2]);
k++;
}
}
}
</script>
in a traditional drop down.. if i wanted one of these items to be formated i could just do
Code:
<option value="p1" style="blabla">EC1 - Central London</option>
if i wanted to add css formating to certain items within my array can this be done directly within the script? thanks