What am I doing wrong: Javascript For Loop
Hi all,
Here's the code:
<script language = "javascript">
function addFillings(newId)
{
document.getElementById("fillsSpan").style.visibil ity = "visible"
var newSel = document.createElement("SELECT")
document.getElementById("fillsSpan").insertBefore( newSel)
newSel.setAttribute('id', newId)
newSel.setAttribute('size', 6)
newSel.setAttribute('multiple', true)
var fArray = new Array()
fArray[0] = "cheese"
fArray[1] = "ham"
fArray[2] = "pickle"
fArray[3] = "beef"
fArray[4] = "turkey"
fArray[5] = "tuna"
for (i = 0; i<=5; i++)
{
var oAdd = fArray[i]
document.getElementById(newId).options[i] = new Option(oAdd)
}
}
function overSeeFills(noOfEls)//Number of sandwiches requested here = number of select boxes to create
{
for(i = noOfEls; i <= noOfEls; i++)
var newId = document.getElementsByTagName("INPUT").length + Math.floor(Math.random() * 123)
var newEl = new addFillings(newId)//create an id and pass it into my object, so I can reference the select box later }
</script>
I am trying to call my own object inside a for loop. The purpose is to create the same amount of select boxes as the user inputs for their menu choice. SO if the user wanted two paninis then I would offer two fillings select boxes, one for each panini. So what I've tried to do is pass the value of the input box into addfillings(noOfEls), in order to pass that into my loop and carry out that many instantiations of the creation of select boxes. (Hope that makes sense).
Help!
Cheers
Joe
__________________
\'sync\' <cr>
The name specified is not recognized as an internal or external command, operable program or batch file.
|