|
Select list will not display
I've managed to fill a select elements option with a javascript array. Now I want it to display what the user selected in an alert window when he/she hits submit. I'm at wits end here can anybody help? here is my code:
<script language="JavaScript">
<!-- // JavaScript Week 6 Homework: Pizza D'Action
var choose = new Array(); // when the page is loaded, declare a variable as an Array
// add code here, to create the Array that will be used to create the Select
choose[0] = "check"
choose[1] = "money order"
choose[2] = "visa"
choose[3] = "master card"
choose[4] = "AMEX"
choose[5] = "cash"
choose[6] = "other"
function seeForm(){ {
// add code here, to loop through all buttons in pdel (pickup or delivery) and show which was selected
// loop through all buttons in agegroup
for( var i=0; i<(document.forms[0].pdel.length); i++ ) {
if(document.forms[0].pdel[i].checked) {
alert("You selected " + document.forms[0].pdel[i].value);
}
}
}
// add code here, to show which option was selectd in the Select payby (payment method)
if (choose[0] == true ){
alert("you chose check");
}
else if (payby == "money order" ){
alert("you chose money order");
}
else if (payby == "visa" ){
alert("you chose visa");
}
else if (document.forms[0].pdel[i].checked) {
var del = document.forms[0].pdel[i].value;
alert("Delivery method: " + del + "\nPayment Method: " + payby );
makeWin();}
} // end of function seeForm()
//-->
</script>
<td><SELECT name="payby" >
<script language="JavaScript">
<!-- // this will execute when the page is loaded, and build the select statement
for( var i=0; i < choose.length; i++ ) // a loop, will execute for each entry in array choose
{
document.write("<OPTION>"+choose[i]); // "write" into the Select statement, the HTML to create an Option for this entry in array choose
}
|