Re: Switch() Statement Not Working
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Switch() Statement Not Working

From: me <me@mememe.com>
Date: Sun Feb 05 2006 - 18:28:56 CET

On Tue, 31 Jan 2006 11:09:33 -0800, rdavis7408 wrote:

> Hello, I have four textboxes that the user enters the price per gallon
> paid at the pump, the mileage per gallon and I would like to then
> calculate the cost per gallon and use a switch statement to pull a
> value based on the price per gallon.
>
> For example if the price of fuel is 2.44 per gallon and the enter that
> they get 5.9 miles per gallon the cost of that mile is $.41. Then based
> on the cost per gallon of 2.44 we might pay them another $.20 per
> gallon based off of the numbers in the switch statement.
>
> The calculation worked until I added the switch statement. Why is that?
> Can anyone help?
>
> Thanks ahead of time. Below is the script:
>

Others have commented on a few of the misinterpretations in the code. All
logical guesses, but not close enough :)

The best advice I can give anyone using JS is to go for the excellent
O'Reilly reference:

http://www.oreilly.com/catalog/jscript4/index.html

and you could do worse than have the DHTML reference to had as well:

http://www.oreilly.com/catalog/dhtmlref2/index.html

Superb references if you want more than a lightweight quick-and-dirty
understanding of each.

For a decent JS website try

http://www.crockford.com/
Received on Tue Feb 7 21:35:22 2006