473,246 Members | 1,491 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,246 software developers and data experts.

multiple questions for javascript pros

6
Hello,

I'm Greg, a beginner in javascript, and I have a homework at university, to create a sort of a "pizza online-order website". I must give the option (through a FORM) for the buyer to specify how much, how large and what kind of pizza he wants to eat, and wether he wants it to be delivered or not. That part is done, sort of, I searched for a lot of things for my javascript on the internet, and found things, but now I'm stuck, so I need help. I need to count the cost, for example there are the pizzas, if you say you want two, and you enter 2 to one of the textboxes, the Count button should calculate the order. But I just don't know how to do it, I tried, but somehow, it doesn't seem to allow my script there, and if that part is not working, the other parts of the script are also not working! Also, I don't know that, if it's counted, how can I print the sum of the costs to the other side of the table, for example into a label.

The site is at:

http://irx.inf.elte.hu/~begoaai/pizzaboy/index2.html

The code is pretty messy, e.g. there are three buttons which do the same, but anyway...
May 6 '07 #1
2 1209
pbmods
5,821 Expert 4TB
if you say you want two, and you enter 2 to one of the textboxes, the Count button should calculate the order. But I just don't know how to do it,
Looking at your code, probably the easiest way to calculate the costs (without using custom attributes, which your instructor probably wouldn't approve of), would be to create an object to store the per-pizza cost and then write a function that totals up the cost:

Expand|Select|Wrap|Line Numbers
  1. var pizzaCosts = {
  2.     p1db:    6.75,
  3.     p2db:    7.80,
  4.     etc.
  5. };
  6.  
  7. function totalOrder() {
  8.     var theTotal = 0;
  9.  
  10.     for(var i = 0; i < 16; i++)
  11.         theTotal += (pizzaCosts['p' + i + 'db'] * parseInt(document.getElementById('p' + i + 'db').value));
  12.  
  13.     document.getElementById('theTotal').value = theTotal;
  14. }
  15.  
I tried, but somehow, it doesn't seem to allow my script there,
You'll have to explain that one in more detail.

Also, I don't know that, if it's counted, how can I print the sum of the costs to the other side of the table, for example into a label.
Welcome to DOM, bendes.

http://www.w3schools.com/htmldom/default.asp
May 6 '07 #2
bendes
6
Wow, thanks for the fast and accurate answer, I will try and learn from what you've written down. If I have other questions, I will ask them later, now I try and concentrate what I can do with the script.

Thanks again for the help,

Greg
May 6 '07 #3

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

Similar topics

15
by: binnyva | last post by:
Hello Everyone, I have just compleated a JavaScript tutorial and publishing the draft(or the beta version, as I like to call it) for review. This is not open to public yet. The Tutorial is...
39
by: Hareth | last post by:
C# 2005 express & vb 2005 express: 1. During runtime, I can edit my codes in C#..... How come this cannot be done in VB? it says ...."read-only" during runtime...... 2. Why does vb...
0
by: rayone | last post by:
Hi folks. I need advice. 2 options, which do you think is the better option to display/retrieve/report on the data. Keep in mind reporting (Crystal), SQL Performance, VB Code, usability,...
1
by: sneha123 | last post by:
There will be some 20 questions and for each question there will be 4 choices.what i want to do is to select multiple answers by clicking the checkbox. i m using asp.net,vb.net pls help me we...
7
by: Dave | last post by:
Apologies for the newbie question. I have created a vb.net program for my company that is designed to work with Word Templates (about forty of them that we commonly use) that are selected by the...
4
by: Matt Kruse | last post by:
While developing an internal IE6-only webapp, a discussion started about the 'best' way to apply classes to data tables across multiple pages. The two arguments were: 1. Apply a single class to...
2
by: newjazzharmony | last post by:
All, I'd appreciate it if someone could answer these questions for me. This scenario applies to an ASP dot net application that is deployed in a web farm. 1) Does the application live in a...
16
by: marc_r_bertrand | last post by:
To all asp/db pros: The quiz code below works. But there is a problem when too many questions are answered (radio buttons clicked). I am not an asp pro. So, is there a pro out there or an...
5
by: phpCodeHead | last post by:
I am needing to determine how to go about validating that a field in my form contains only a positive integer. I know that this is fairly simple if the form contains only one element to be...
8
by: Krypto | last post by:
Hi, I have used Python for a couple of projects last year and I found it extremely useful. I could write two middle size projects in 2-3 months (part time). Right now I am a bit rusty and trying...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.