So i'm trying to self learn HTML and Jscript but i cannot figure out for the life of me what i've did wrong in this piece of code, its a drop down question list that asks the user what fruits they like, and their asking to make 9 answers, so this script is to capture those answers and store them in an array but when it breaks outside the loop the last alert does not show, so i can see the array is not actually getting filled.
I used the alerts for bug checking :)
<script>
function submitInfo(passed){
var Fruit = [];
var myForm = passed+"Form";
//alert("here start"+" "+document.getElementById(myForm).length+" "+myForm);
for (var i = 0; i < document.getElementById(myForm).length; i++) {
//alert("in loop");
var myFruit = passed+"Input"+i;
//alert(myFruit+" "+document.getElementById(myFruit).value);
Fruit.push(document.getElementById(myFruit).value);
// var Fruit[i] = document.getElementById(myFruit).value;
alert(Fruit[i]);
}
alert(Fruit[i]);
}
</script>
Thank you in advance for any help, it is appreciaed
var Fruit = new Array()