Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #16410
| Path | csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | JJ <jaejunks_at@_googlemail_dot._com> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Extracting data from a form |
| Date | Fri, 5 Oct 2012 01:34:07 +0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 51 |
| Message-ID | <XnsA0E357D11D116jaejunksgooglemailco@0.0.0.44> (permalink) |
| References | <k4kuc5$pnp$1@gallifrey.nk.ca> |
| Injection-Date | Fri, 5 Oct 2012 01:34:07 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="041275ad72822f875a187f1d67b21734"; logging-data="28488"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/FkEqy0VvfFwYarxXZfH6zO3VOma/qUNo=" |
| User-Agent | Xnews/5.04.25 |
| X-Face | \*\`0(1j~VfYC>ebz[&O.]=,Nm\oRM{of,liRO#7Eqi4|!]!(Gs=Akgh{J)605>C9Air?pad{sSZ09u+A7f<^paR"/NH_#<mE1S"hde\c6PZLUB[t/s5-+Iu5DSc?P0+4%,Hl |
| Cancel-Lock | sha1:J/yn1ukjd1DjScK8ZQ3mSI5fnwM= |
| Xref | csiph.com comp.lang.javascript:16410 |
Show key headers only | View raw
doctor@doctor.nl2k.ab.ca (The Doctor) wrote:
> We are working with
>
> <html><head>
[snip]
> End HTML
>
> All right we want to incorpration the Quantity Value
>
> So the Total Price = Sum of Quantity (x) * Price (x) .
>
>
> 277 <= x <= 278 .
>
> In this case.
>
> How does one incorporate this into the total?
Use below "count" function replacement. The input quantity value in the
form must be a valid number greater than zero. Otherwise, if it's
negative or invalid number, it will be assumed as zero. The "price277",
"price278" form fields value must be a valid number for the course price,
or the code won't work.
You might want to learn the code instead of copy-paste-forget. Feel free
to ask if you don't understand something.
//courseNumber must be a number or a string of number.
//e.g.: 277, "278", etc.
function getTotalCoursePrice(courseNumber) {
if (calc['price'+courseNumber].checked){
var price = parseInt(calc['price'+courseNumber].value.trim());
var qty = parseInt(calc['quantity'+courseNumber].value.trim());
if (isNaN(qty) || (qty < 0)) qty = 0;
} else {
var price = 0;
var qty = 0;
}
return price * qty;
}
function count() {
var i, result = 0;
//loop the count for course number 277 to 278 inclusive.
for (i = 277; i <= 278; i++) i += getTotalCoursePrice(i);
calc.charge_total.value = result.toFixed(2);
//don't submit if total price is zero
return result > 0;
}
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Extracting data from a form doctor@doctor.nl2k.ab.ca (The Doctor) - 2012-10-04 21:16 +0000
Re: Extracting data from a form Danny <dann90038@gmail.com> - 2012-10-04 15:31 -0700
Re: Extracting data from a form JJ <jaejunks_at@_googlemail_dot._com> - 2012-10-05 01:34 +0000
Re: Extracting data from a form Dr J R Stockton <reply1240@merlyn.demon.co.uk.invalid> - 2012-10-06 19:12 +0100
Re: Extracting data from a form "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-10-07 07:34 +0000
Re: Extracting data from a form doctor@doctor.nl2k.ab.ca (The Doctor) - 2012-10-08 20:22 +0000
Re: Extracting data from a form "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-10-08 20:52 +0000
csiph-web