Article View: aus.computers.java
Article #841Re: Price calculator?
From: Alan
Date: Sun, 07 May 2000 00:00
Date: Sun, 07 May 2000 00:00
49 lines
2231 bytes
2231 bytes
If they are choosing products in a page using a form then Javascript is
pobably the easiest way
you could use something like
function compute(f)
{
var f = document.pricing; // This is the form we'll we working with;
var count1 = parseInt(f.count1.value);
if (isNaN(count1)) { count1 = 0; f.count1.value = "0"; }
f.subt1.value = 3.4 * count1;
var count2 = parseInt(f.count2.value);
if (isNaN(count2)) { count2 = 0; f.count2.value = "0"; }
f.subt2.value = 3.4 * count2;
f.total.value = parseFloat(f.subt1.value) +
parseFloat(f.subt2.value)
}
<FORM NAME="pricing">
<INPUT TYPE=text NAME="count1" SIZE=12 onChange="compute()">of $3.40<INPUT
TYPE=text NAME="subt1" SIZE=12 onChange="compute()"><BR>
<INPUT TYPE=text NAME="count2" SIZE=12 onChange="compute()">of $3.40<INPUT
TYPE=text NAME="subt2" SIZE=12 onChange="compute()"><BR>
<INPUT TYPE=text NAME="total" SIZE=12 onChange="compute()">
</FORM>
do if you are not doing it in a form you could do some server side code
Alan
"Sarah Chancel" <schancel@club-internet.fr> wrote in message
news:8f3dsc$s5n$1@front3m.grolier.fr...
> Hi,
> I'm looking for applet that'll calculate the price the client has to pay
> when ordering a certain amount of products on my site. I'm actually not
sure
> if I'm supposed to look for an applet or use javascript...
> The program will have to give me the total amount due at the bottom of the
> page...
> I hope you understand what I mean, I'd really appreciate some help,
> Thanks,
> Sarah.
>
>
Technical Details
Message-ID:
<WJdR4.15011$PL4.369603@ozemail.com.au>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<8f3dsc$s5n$1@front3m.grolier.fr>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d6db,d63aa8060e07005 X-Google-Attributes: gid10d6db,public From: "Alan" <aboldock@camtech.net.au> Subject: Re: Price calculator? Date: 2000/05/07 Message-ID: <WJdR4.15011$PL4.369603@ozemail.com.au> X-Deja-AN: 620260168 Distribution: world References: <8f3dsc$s5n$1@front3m.grolier.fr> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 X-Trace: ozemail.com.au 957704182 203.38.172.152 (Sun, 07 May 2000 22:56:22 EST) Organization: OzEmail Ltd, Australia X-MSMail-Priority: Normal NNTP-Posting-Date: Sun, 07 May 2000 22:56:22 EST Newsgroups: aus.computers.java