This is my first post so if i happen to post incorrectly, please let me know how to fix.
What I am trying to do:
1: Display Checkboxes and Radios in alert box
2: My alert box already has variables in it and I have zero idea how to incorporate this.
3: I attempted and failed numerous times with looping the checkboxes and have it displayed in the alert box with the other information, but no luck to me.
The end result should be when I click on submit.. an alert box with all the input data is there with the options chosen.
Ex:
Alert:
Customer
Address
City, State, Zip
Size: Small
Toppings: Extra Cheese, Olives
This is my code that is clearly wrong and not sure how to do this! I can only assume if i can figure out the checkboxes, the radios are very similar.. Please HELP
Expand|Select|Wrap|Line Numbers
- function doSubmit()
- {
- var customer = document.PizzaForm.customer.value;
- var address = document.PizzaForm.address.value;
- var city = document.PizzaForm.city.value;
- var state = document.PizzaForm.state.value;
- var zip = document.PizzaForm.zip.value;
- var phone = document.PizzaForm.phone.value;
- var email = document.PizzaForm.email.value;
- if (document.PizzaForm.customer.value == false)
- {
- alert("Please provide your name");
- if (document.PizzaForm.address.value == false)
- alert("Please provide your address");
- if (document.PizzaForm.city.value == false)
- alert("Please provide your city");
- if (document.PizzaForm.state.value == false)
- alert("Please provide your state");
- if (document.PizzaForm.zip.value == false)
- alert("Please provide a zip code");
- if (document.PizzaForm.phone.value == false)
- alert("Your digits, please!");
- if (document.PizzaForm.email.value == false)
- alert("Email address is missing");
- return;
- }
- var message ="Customer: " + customer + '\n' + "Address: " + address + '\n' + "City: " + city + '\n' + "State: " + state + '\n' + "Zip: " + zip + '\n'+ "Phone: " + phone + '\n' + "Email: " + email + vCollection;
- alert(message)
- return;
- }
- var form =document.PizzaForm;
- var vCollection = document.PizzaForm('toppings');
- function toppingsSelect() {
- alert(vCollection.length);
- for (var i = 0; i < vCollection.length; i++) {
- if (form[0][i].checked) {
- alert(form[0][i].value);
- }
- }
- }