473,686 Members | 3,587 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calculation and onchange

1 New Member
I have an html form with three fields that need to calculate the total and onchange put the amount on a text field, should be simple enough for the gurus, I started it but cannot get it right. Here is the formula:
Logo Solutions: (LIST)
Starter Package - $159
Pro Package - $359
Wholistic Package - $659

Promtional Code: (TEXT)
NU0507

If Starter Discount = -$25
If Pro Discount = -$50
If Wholistic Discount = -$100

Priority Rush: (CHECK)
Priority Rush - +$99

Order Total: (DYNAMIC)
Displays the total

as you can see the package list has the prices, that need to total and if they put in the promo code NU0507
then they get the discount outlined above accordingly, and one more loop is if they check the rush checkbox it adds 99 to total
Simple caclutation, just my javascript is'nt so good, Here is the function I started writing, though with it I could'nt even get the onchage to fire:
Plus also now the total text field has the 659 in it as defualt but does not change as I select the list box.
here is the function as I have it set:
function Change_Selectio n() {
var logo_list = document.getEle mentById("pack" );
var logo_tot = document.getEle mentById("logo_ total");
var curSel = logo_list.optio ns[logo_list.selec tedIndex].value;
switch (curSel) {
case 1:
logo_tot.value = "159";
break;
case 2:
logo_tot.value = "359";
break;
default:
logo_tot.value = "659";
}
}

And here is the form code as I have it now:

<select name="pack" id="pack" onChange="Chang e_Selection()">
<option value="1" selected>
<option value="1" selected>Starte r Package</option>
Starter Package
<option value="2">Pro Package</option>
<option value="3">Wholi stic Package</option>
</select>
</label></td>
</tr>
<tr bgcolor="#fffff f">
<td height="2" bgcolor="#FFFFF F"><span class="style10" >Promo Code </span></td>
<td height="2" colspan="3"><la bel>
<input name="code" type="text" id="code">
</label></td>
</tr>
<tr bgcolor="#fffff f">
<td height="2" bgcolor="#FFFFF F"><span class="style10" >Proirity rush </span></td>
<td height="2" colspan="3"><la bel>
<input name="rush" type="checkbox" id="rush" value="99">
</label></td>
</tr>
<tr bgcolor="#fffff f">
<td height="2" bgcolor="#FFFFF F"><span class="style10" >Total</span></td>
<td height="2" colspan="3"><la bel>
<input name="logo_tota l" type="text" id="logo_total" >
</label></td>
</tr>

if anyone can help it will much be appreasiated!
May 24 '07 #1
3 2280
acoder
16,027 Recognized Expert Moderator MVP
In your switch statement, change the integers to strings, i.e. 1 should be '1', etc.
May 25 '07 #2
gits
5,390 Recognized Expert Moderator Expert
yep ... alternativly you may typecast the curSel-value to numbers:

Expand|Select|Wrap|Line Numbers
  1. // apply that to that switch-statement
  2.  
  3. switch (parseInt(curSel)) {
  4.     // your code here
  5. }
  6.  
May 25 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
yep ... alternativly you may typecast the curSel-value to numbers:
Yes, that too!
May 26 '07 #4

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

Similar topics

1
1562
by: pmarisole | last post by:
I need help in calculating a score from a row of drop-down values. I need to use the onChange to tally the score as the user moves across 9 categories (with drop-down selection of 1-9 or N/A) multiplied by a weighted score. The final column for each employee would be the calculated score. I know how to accomplish this with vbscript but I need it to process on the screen so the user can see the calculated score as they make selections....
2
2190
cassbiz
by: cassbiz | last post by:
I may be in the wrong forum so Ronald don't shoot :) In my code I have an option box to choose a number - works fine. I want to carry over the new value to another field to do a recalculation. Primarily the field "$preis1" to change with the javascript. Here is the code. <script type="text/javascript">
14
2798
by: ap.sakala | last post by:
Hello, How the heck should I make this simple summering of a data without a submit button? Like in an excel sheet I would like to have a couple of cells in a column and as soon the visitor types the number the sum should change, regardless of how many raws there are and based on the setting (adding, multiplying etc).
5
6250
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a user modifies any of the x, y and z values.
2
1797
by: Uncle pablo | last post by:
I was searching ALL over for a javascript to just add up a column of numbers and I found this one here in an old question. It seemed to work great for my purposes EXCEPT it stops adding at four and I have more input fields than that. I tried adjusting the for (var i=1;i<=4;i++) { to for (var i=1;i<=12;i++) { to reflect the number of fields and thinking that was the issue but I got an error message about form elements being invalid. ...
1
1838
by: theflyingminstrel | last post by:
Hi, I’m having some trouble with a Javascript code, and I was wondering if anyone can help: I am trying to build a price estimator that has multiple fields. I would like the first two fields to have a price value based on a quantity price, so for example 1-10 qantity equals $30, 20-30 quantity equals $40 in the “Total” field). The rest of the fields in the following code work as intended whereas they just add based on the price to the right....
4
2431
by: gregincolumbus | last post by:
I am trying to get the financial calculation on this to trigger whenever there is a change to select1. Right now, the user has to click on select2 to trigger the changes. Ideally, a change of select1 1. trigger the population of select2 (and set it initially to 0) 2. make the text fields disappear 3. trigger the financial calculation to reflect the select1 choice. Any help would be greatly appeciated !
1
1076
by: mloraditch | last post by:
I've got some code that is supposed to calculate some values on a form and generate a total. It seems like it should work but it's definetly not, I am getting objected expected errors from the line(~26) with the onChange event, but I can't see that anything is missing. Any help is appreciated. <html> <head><title>IOCC</title> <script> <!-- function InvoiceTotal(form) { var a = (form.#tickets.value != '') ?...
12
2548
by: brossyg | last post by:
I have a very simple price times quantity calculation. The input is STWCORQuant: <input name="STWCORQuant" class="contactitalicbold" id="STWCORQuant" onChange="javascript:STWCORPrice();" value="0" size="8" style="text-align: right; font-family: ver"> And the fucntion is STWCORPrice(): <script language="javascript" type="text/javascript">
0
8514
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9050
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8932
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8778
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7598
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6439
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5795
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4307
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2205
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.