473,416 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

How To Loop Checkboxes and Radios and Display in Alert

Hi All,
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
  1.  function doSubmit()
  2. {
  3.   var customer = document.PizzaForm.customer.value;
  4.   var address = document.PizzaForm.address.value;
  5.   var city = document.PizzaForm.city.value;
  6.   var state = document.PizzaForm.state.value;
  7.   var zip = document.PizzaForm.zip.value;
  8.   var phone = document.PizzaForm.phone.value;
  9.   var email = document.PizzaForm.email.value;
  10.  
  11.  
  12.  
  13.  if (document.PizzaForm.customer.value == false)
  14.  {
  15.  alert("Please provide your name");
  16.  if (document.PizzaForm.address.value == false)
  17.  
  18.  alert("Please provide your address");
  19.  if (document.PizzaForm.city.value == false)
  20.  alert("Please provide your city");
  21.  if (document.PizzaForm.state.value == false)
  22.  alert("Please provide your state");
  23.  if (document.PizzaForm.zip.value == false)
  24.  alert("Please provide a zip code");
  25.  if (document.PizzaForm.phone.value == false)
  26.  alert("Your digits, please!");
  27.  if (document.PizzaForm.email.value == false)
  28.  alert("Email address is missing");
  29.  return;
  30.  }
  31.  
  32.  
  33.  var message ="Customer: " + customer + '\n' + "Address: " + address + '\n' + "City: " + city + '\n' + "State: " + state + '\n' + "Zip: " + zip + '\n'+ "Phone: " + phone + '\n' + "Email: " + email + vCollection;
  34.  alert(message)
  35.  return;
  36. }
  37.  
  38.  
  39.   var form =document.PizzaForm; 
  40.   var vCollection = document.PizzaForm('toppings');    
  41.  
  42. function toppingsSelect() {
  43.  
  44.       alert(vCollection.length);
  45.  
  46. for (var i = 0; i < vCollection.length; i++) {
  47.  
  48.   if (form[0][i].checked) { 
  49.  
  50.      alert(form[0][i].value);
  51.    }
  52.   }
  53.  }
  54.  
Oct 22 '10 #1
0 1186

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: StepH | last post by:
Hi, I'm building a little application, which the goal is to: 1./ Collect data via Serial line and or via a file (for playback). 2./ Display these data as graph, oscilloscope, ... How manage...
3
by: addi | last post by:
All, I will be eternally greatful if someone can provide snippet of code, URL or reference material that shows how to display data in a "n colums * n rows" format. I am new to ASP and have...
11
by: shree | last post by:
Hello everyone, I'm writing a form which will have a group of checkboxes. When user selects one checkbox, it will automatically disable the rest of the checkboxes in the group. I'm able to...
3
by: bitsyboffin | last post by:
Hi all, does anybody know of a bug in MacIE which prevents style.display = 'none' and style.visibility = 'hidden' from "sticking" in MacIE? I'm making some graphical checkboxes & radios (I know,...
13
by: Gunnar | last post by:
Hello, I am running into problems with a simple function which should change the style.display properties from 'block' to 'none'. I am able to change them from 'none' to 'block' as expected. ...
4
by: ghadley_00 | last post by:
I have a MS access database which has entries (each of which has a name field) and uses a form to make new entries. I would like to put together code that will run when a new entry's name is...
2
by: | last post by:
While I can extract the option value from the following: <Select name='Keystring' MULTIPLE> <option value='1' name='status'>Pending</option> ..... </select> I cannot seem to extract the...
0
by: krokador | last post by:
This is doing my head in... We're starting to migrate our report-printing and such (forms included) to pdf - using xml files and nFOP with asp.net. In this case I have to print out a form which...
1
by: azgaranoop | last post by:
Hi, i want to display a alert box when a user leave my site.... Means if a user clck on X button i.e on top right corner of the browser or the user click on the address bar and try to change the...
23
by: Marge | last post by:
This may be in the wrong forum, but here goes. How can I display an alert in the users browser window from an asp page. For example, a welcome message. I know I can do this with response.write,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.