By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,872 Members | 2,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,872 IT Pros & Developers. It's quick & easy.

Switch() Statement Not Working

P: n/a
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:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<link href="fsc.css" rel="stylesheet" type="text/css">
</head>

<body>

<script language="JavaScript">
function FuelCalculator(f)
{
var A;
A= Math.round((f.ppg.value/f.mpg.value)*100);
f.cpg.value = "$"+(A/100);
}

var b;
b=this.form.ppg.value
switch(b)
{
Case >=1.25 && <=1.30:
this.form.dlnt.value=.01;
Case >=1.31 && <=1.369:
this.form.dlnt.value=.02;
Case >=1.37 && <=1.429:
this.form.dlnt.value=.03;
default:
this.form.dlnt.value=.99

}

</script>

<form action="">

<table width="351">
<tr>
<td width="213"> Cents per gallon:</td>
<td width="60" > <input name="ppg" type="text"
style="text-align:center" value="0" size="10">
</td>
</tr>
<tr>
<td>Miles per gallon:</td>
<td> <input name="mpg" type="text" value="0" size="10"
style="text-align:center">
</td>
</tr>
<tr>
<td>Fuel Cost Per Mile: </td>
<td > <input name="cpg" type= "text" disabled="true" value="0"
size="10" style="text-align:center">
</td>
<tr>
<td>Dillon Fuel Surcharge Payment: </td>
<td> <input name="dlnt" type="text" disabled="true" value="0"
size="10" style="text-align:center">
</td>
<tr>
<td colspan="2" ><input name="button" type="button"
onClick="FuelCalculator(this.form);" value="Calclulate"> </td>
</tr>
<td><input name="FSC" type="button" onClick="switch(b)"
value="FSC"></td>

</table>

</form>
</body>
</html>

Jan 31 '06 #1
Share this Question
Share on Google+
19 Replies


P: n/a
wrote on 31 jan 2006 in comp.lang.javascript:
switch(b)
{
Case >=1.25 && <=1.30:
this.form.dlnt.value=.01;


It is all in the name:

case is lowercase!

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 31 '06 #2

P: n/a
Evertjan. wrote on 31 jan 2006 in comp.lang.javascript:
wrote on 31 jan 2006 in comp.lang.javascript:
switch(b)
{
Case >=1.25 && <=1.30:
this.form.dlnt.value=.01;


It is all in the name:

case is lowercase!


and give me a break:

you will have to use break;

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 31 '06 #3

P: n/a

rd********@gmail.com wrote:
<script language="JavaScript">
The language attribute is deprecated, use the type attribute instead:

<script type = "text/javascript">
b=this.form.ppg.value
This statement is error-prone. Instead give your form a name and
access its elements in the following fashion:

var b = document.forms["formName"].elements["ppg"].value;
switch(b)
{
Case >=1.25 && <=1.30:
this.form.dlnt.value=.01;
Case >=1.31 && <=1.369:
this.form.dlnt.value=.02;
Case >=1.37 && <=1.429:
this.form.dlnt.value=.03;
default:
this.form.dlnt.value=.99

}


1. It is not 'Case', but should be 'case' with a lowercase C.
2. You should have a 'break' after one or more cases. And a 'break'
after the default case.
3. The switch construct does not deal with a range of values. You
should instead use if...else statements instead.

var dintVal = .99;

if(b >= 1.25 && b <= 1.3)
{
dintVal = .01
}
else if(b >= 1.31 && b <= 1.369)
{
dintVal = .02
}
else if(b >= 1.37 && b <= 1.429)
{
dintVal = .03;
}

document.forms["formName"].elements["dInt"].value = dintVal;

Jan 31 '06 #4

P: n/a
rd********@gmail.com writes:
The calculation worked until I added the switch statement. Why is that? switch(b)
{
Case >=1.25 && <=1.30:
this.form.dlnt.value=.01;
Case >=1.31 && <=1.369:
this.form.dlnt.value=.02;
Case >=1.37 && <=1.429:
this.form.dlnt.value=.03;
default:
this.form.dlnt.value=.99

}


You are guessing blindly. That rarely works in programming, since
computers are notoriously bad at guessing what you really meant.

The syntax of a case statement is:
case <expression>: <statement>

Example:

switch(num){
case 1: // something for 1
break;
case 2: case 3: // something for 2 or 3
break;
default: // ...
}

In your case, you want to match intervals, not values, so
a switch statement isn't the immediate choice. Instead
use a sequence of if-statements:

if (b >= 1.25 && b <= 1.30) {
this.form.dlnt.value=.01;
} else if (b > 1.30 && b < 1.37) {
...
} else if (b >= 1.37 && b < 1.43) {
...
} else {
...
}
You can get the same effect with a switch, but it's not really
smarter, and it's much less readable.

switch(true) {
case (b >= 1.25 && b <= 1.30) :
this.form.dlnt.value=.01;
break;
case (b > 1.30 && b < 1.37) :
...
break;
...
}

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Feb 1 '06 #5

P: n/a

<rd********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
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:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<link href="fsc.css" rel="stylesheet" type="text/css">
</head>

<body>

<script language="JavaScript">
function FuelCalculator(f)
{
var A;
A= Math.round((f.ppg.value/f.mpg.value)*100);
f.cpg.value = "$"+(A/100);
}

var b;
b=this.form.ppg.value
switch(b)
{
Case >=1.25 && <=1.30:
this.form.dlnt.value=.01;
Case >=1.31 && <=1.369:
this.form.dlnt.value=.02;
Case >=1.37 && <=1.429:
this.form.dlnt.value=.03;
default:
this.form.dlnt.value=.99

}

</script>

<form action="">

<table width="351">
<tr>
<td width="213"> Cents per gallon:</td>
<td width="60" > <input name="ppg" type="text"
style="text-align:center" value="0" size="10">
</td>
</tr>
<tr>
<td>Miles per gallon:</td>
<td> <input name="mpg" type="text" value="0" size="10"
style="text-align:center">
</td>
</tr>
<tr>
<td>Fuel Cost Per Mile: </td>
<td > <input name="cpg" type= "text" disabled="true" value="0"
size="10" style="text-align:center">
</td>
<tr>
<td>Dillon Fuel Surcharge Payment: </td>
<td> <input name="dlnt" type="text" disabled="true" value="0"
size="10" style="text-align:center">
</td>
<tr>
<td colspan="2" ><input name="button" type="button"
onClick="FuelCalculator(this.form);" value="Calclulate"> </td>
</tr>
<td><input name="FSC" type="button" onClick="switch(b)"
value="FSC"></td>

</table>

</form>
</body>
</html>


It appears you are mixing VB's "Select case" syntax with Javascript's
"switch" syntax, and the result is you missed'em both. Easy mistake - take
a look at
http://devguru.com for a reference on both VB and Javascript.
Feb 1 '06 #6

P: n/a
Hal Rosser wrote:
[Full quote]
<http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>
It appears you are mixing VB's "Select case" syntax with Javascript's
"switch" syntax, and the result is you missed'em both. Easy mistake -
take a look at
http://devguru.com for a reference on both VB and Javascript.


devguru.com contains a lot of factually incorrect and obsolete
information about JS/ECMAScript and is therefore not recommended.
PointedEars
Feb 1 '06 #7

P: n/a
web.dev wrote:
rd********@gmail.com wrote:
b=this.form.ppg.value
This statement is error-prone.


Nonsense.
Instead give your form a name and access its elements in the following
fashion:

var b = document.forms["formName"].elements["ppg"].value;


No, the approach using the `form' property was the better one, however it
only works if used in the right place.

<meta http-equiv="Content-Script-Type" content="text/javascript">
...
<script type="text/javascript">
function fuelCalculator(o)
{
var es;
if (o && o.form && (es = o.form.elements))
{
var b = +es['ppg'].value;
var A = Math.round((b / es['mpg'].value) * 100);
es['cpg'].value = "$" + (A / 100);

var t = es['dlnt'];

// To use switch..case..default instead, one could use the
// Interval prototype from my JSX:math.js instead; it provides
// a getIntervalIndex() method which returns the numeric array
// index of the interval that contains a value.

if (b >= 1.25 && b <= 1.30)
{
t.value = 0.01;
}
else if (b >= 1.31 && b <= 1.369)
{
t.value = 0.02;
}
else if (b >= 1.37 && b <= 1.429)
{
t.value= 0.03;
}
else
{
t.value= 0.99;
}
}
}

document.write('<input type="button" name="btn1"'
+ ' onclick="fuelCalculator(this);">');
</script>
PointedEars
Feb 1 '06 #8

P: n/a

Thomas 'PointedEars' Lahn wrote:
web.dev wrote:
rd********@gmail.com wrote:
b=this.form.ppg.value


This statement is error-prone.


Nonsense.
Instead give your form a name and access its elements in the following
fashion:

var b = document.forms["formName"].elements["ppg"].value;


No, the approach using the `form' property was the better one, however it
only works if used in the right place.


In his script, doesn't "this" reference the global window object?
Isn't that why it's error-prone? Otherwise, I do agree that
"this.form" would've been better if used in the right place.

Feb 1 '06 #9

P: n/a
web.dev wrote:
Thomas 'PointedEars' Lahn wrote:
web.dev wrote:
> rd********@gmail.com wrote:
>> b=this.form.ppg.value
>
> This statement is error-prone.
Nonsense.
> Instead give your form a name and access its elements in the following
> fashion:
>
> var b = document.forms["formName"].elements["ppg"].value;


No, the approach using the `form' property was the better one, however it
only works if used in the right place.


In his script, doesn't "this" reference the global window object?


It probably refers to the Global Object there. That is not necessarily a
Window object or the same object the global `window' property refers to.
Isn't that why it's error-prone?
AFAIK, it is an error in the context used by the OP, not only error-prone.
Or can you name any UA where it would work with the OP's HTML code?
Otherwise, I do agree that "this.form" would've been better if used in the
right place.


ACK
PointedEars
Feb 1 '06 #10

P: n/a
In article <11****************@PointedEars.de>, Thomas 'PointedEars'
Lahn <Po*********@web.de> writes

<snip>
if (b >= 1.25 && b <= 1.30)
{
t.value = 0.01;
}
else if (b >= 1.31 && b <= 1.369)
{
t.value = 0.02;
}
else if (b >= 1.37 && b <= 1.429)
{
t.value= 0.03;
}
else
{
t.value= 0.99;
}

<snip>

It would be better if there was only one number in each if condition.
There is then less risk of typing errors and it should be easier to
proof-read.

if (b < 1.25)
t.value = 0.99 // illegal value

else if (b <= 1.3)
t.value = 0.01 // interval 0

else if (b < 1.31)
t.value = 0.99 // illegal value, gap between intervals

else if (b <= 1.369)
t.value = 0.02 // interval 1

else if (b < 1.37)
t.value = 0.99 // illegal value, gap between intervals

else if (b <= 1.429)
t.value = 0.03 // interval 2

else
t.value = 0.99 // illegal value

I'm also very suspicious of those gaps between the intervals.

John
--
John Harris
Feb 1 '06 #11

P: n/a
JRS: In article <KH**************@jgharris.demon.co.uk>, dated Wed, 1
Feb 2006 21:16:39 remote, seen in news:comp.lang.javascript, John G
Harris <jo**@nospam.demon.co.uk> posted :
In article <11****************@PointedEars.de>, Thomas 'PointedEars'
Lahn <Po*********@web.de> writes

<snip> I'm also very suspicious of those gaps between the intervals.


Agreed. It must have been past Ears' bedtime, since otherwise he should
have spotted that.

There's a more important potential problem.

The numbers in the conditions, numbers such as 1.37, are literals and
will take whatever value of a floating-point binary IEEE Double is
deemed nearest. The only two-place decimal fractions represented
exactly are .00 .25 .50 .75.

In this case, the quantities being compared with those may well
themselves be effectively two-place literals rather than arithmetically-
calculated values; but that will not necessarily always hold.
Arithmetically-calculated values are subject to rounding error, unless
everything can be held exactly in a Double. However, the OP's "rules"
are evidently written with exact two-place decimals in mind.

The OP's code should very probably be modified to work in terms of cents
rather than dollars; integers up to 2^53 are held exactly.

Writing it as a critical value table, using a well-tested lookup
function, might well make it more maintainable.

Using a decimal point without a digit on each side is deprecated, as
liable to lead to transcription error.

<FAQENTRY> ISTM that the FAQ does not address the desirability of
working in integers whenever practicable, such as with currency; and
that it should.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Feb 2 '06 #12

P: n/a
> devguru.com contains a lot of factually incorrect and obsolete
information about JS/ECMAScript and is therefore not recommended.
PointedEars


Is there a good web site ?
Devguru may have errors, but its better than no reference at all.
Feb 3 '06 #13

P: n/a
Hal Rosser said the following on 2/3/2006 2:58 AM:
devguru.com contains a lot of factually incorrect and obsolete
information about JS/ECMAScript and is therefore not recommended.
PointedEars
Is there a good web site ?


http://jibbering.com/faq and related links therein.
Devguru may have errors, but its better than no reference at all.


Not true. Bad sites are worse than no site. Once you find a good site,
you have to re-learn it all after you wasted your time learning bad
habits/code.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 3 '06 #14

P: n/a
me
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/

Feb 5 '06 #15

P: n/a
me wrote:
Others have commented on a few of the misinterpretations in the code. All
logical guesses, but not close enough :)
You are talking nonsense.
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
This is recommended in the FAQ only because all other books are worse.
and you could do worse than have the DHTML reference to had as well:

http://www.oreilly.com/catalog/dhtmlref2/index.html
You could do worse, but this is bad enough. A book published four years ago
is certainly obsolete. The examples in the example chapter prove that.
Superb references if you want more than a lightweight quick-and-dirty
understanding of each.


Wrong.

BTW: Are you Kamal Sharma of Nugen.net, owner of mememe.com, or do you have
his explicit permission to use his second-level domain? If not, you better
stop this domain abuse at once.
PointedEars
Feb 5 '06 #16

P: n/a
On Sun, 05 Feb 2006 19:20:40 +0100, Thomas 'PointedEars' Lahn wrote:
me wrote:
Others have commented on a few of the misinterpretations in the code. All
logical guesses, but not close enough :)
You are talking nonsense.


Perhaps I should clear something up right off the bat; the "not close
enough" remark was made in response to the guesses made in the OPs
original code, not the subsequent responses, most of which hit the nail on
the head.

Perhaps this acknowledgement puts you in a better temper?
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


This is recommended in the FAQ only because all other books are worse.


Who's FAQ? Why should I care? And in any case, why does this have
relevance? I recommend it to the OP from my personal experience (and the
response of others I recommend it to).

Is your own personal experience of this book different?
and you could do worse than have the DHTML reference to had as well:

http://www.oreilly.com/catalog/dhtmlref2/index.html
You could do worse, but this is bad enough. A book published four years
ago is certainly obsolete. The examples in the example chapter prove
that.


Ah, so you haven't read that one *either*?

Once again, I am aware of the age of the book, and have had a steady
supply of others to compare it to. It is still without peer if you want to
*grok* DHTML/JS in a platform neutral manner, rather than firefight a
problem or hack something together.
Superb references if you want more than a lightweight quick-and-dirty understanding of each.


Wrong.


LOL, on what basis do you make *that* assertion, exactly?

BTW: Are you Kamal Sharma of Nugen.net, owner of mememe.com, or do you
have his explicit permission to use his second-level domain? If not,
you better stop this domain abuse at once.

You've Googled! How sweet.

But it's a fair point, I keep forgetting to reset my profile.

I'd much prefer to use my real name to tell you to piss off, should it
come to that.

Happy now?

PointedEars


Feb 5 '06 #17

P: n/a
Sean Inglis wrote:
On Sun, 05 Feb 2006 19:20:40 +0100, Thomas 'PointedEars' Lahn wrote:
me wrote:
Others have commented on a few of the misinterpretations in the code.
All logical guesses, but not close enough :) You are talking nonsense.


Perhaps I should clear something up right off the bat; the "not close
enough" remark was made in response to the guesses made in the OPs
original code, not the subsequent responses, most of which hit the nail on
the head.


ACK
Perhaps this acknowledgement puts you in a better temper?
It is not my temper that is the matter here. But JFYI, as you are so
concerned with my health, I have been quite calm when I was writing that
and I am now.
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

This is recommended in the FAQ only because all other books are worse.


Who's FAQ?


The FAQ of this newsgroup.
Why should I care?
Because you are not a fool?
And in any case, why does this have relevance?
Because it is the FAQ of _this_ newsgroup, written by and contributed to by
its accepted regulars, people whose knowledge about and understanding of
the subjects discussed probably exceeds yours by orders of magnitude?
I recommend it to the OP from my personal experience (and the ^^^^^^^ response of others I recommend it to). ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Pardon?
Is your own personal experience of this book different?
Unfortunately, it is. Enough bad examples from it have been posted here.
and you could do worse than have the DHTML reference to had as well:

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

You could do worse, but this is bad enough. A book published four years
ago is certainly obsolete. The examples in the example chapter prove
that.


Ah, so you haven't read that one *either*?


Of course not. Why should I read or even buy a book that is obviously
obsolete and uses so many bad examples in just one chapter? Would you?
Once again, I am aware of the age of the book, and have had a steady
supply of others to compare it to. It is still without peer if you want to
*grok* DHTML/JS in a platform neutral manner, rather than firefight a
problem or hack something together.
That there is nothing better (which I seriously doubt) does not make it
any good.
Superb references if you want more than a lightweight
quick-and-dirty understanding of each.

Wrong.


LOL, on what basis do you make *that* assertion, exactly?


Personal experience, including experience of postings in this newsgroup
of much higher quality.
BTW: Are you Kamal Sharma of Nugen.net, owner of mememe.com, or do you
have his explicit permission to use his second-level domain? If not,
you better stop this domain abuse at once.


You've Googled!


I have not, whois(1) sufficed. For some of us, the Internet is more than
the Web.
How sweet.
I am glad I could amuse you. You are easily impressed, yes?
But it's a fair point, I keep forgetting to reset my profile.

I'd much prefer to use my real name to tell you to piss off, should it
come to that.
I am sorry to say that your vocabulary does not form
a non-empty intersecting set with mine. [psf 2.13]

I do not care much about your real name, at least not in this NetNews
top-level hierarchy. I care about (misguided) network abuse, and you
should care about that, too.
Happy now?


That was never the point. However, your From header is still not
acceptable as there is no .house top-level domain (yet). See also
<URL:http://giganews.com/legal/aup.html>
HTH

PointedEars
Feb 5 '06 #18

P: n/a
On Sun, 05 Feb 2006 21:44:56 +0100, Thomas 'PointedEars' Lahn wrote:
Sean Inglis wrote:
On Sun, 05 Feb 2006 19:20:40 +0100, Thomas 'PointedEars' Lahn wrote:
me wrote:
Others have commented on a few of the misinterpretations in the code.
All logical guesses, but not close enough :)
You are talking nonsense.
Perhaps I should clear something up right off the bat; the "not close
enough" remark was made in response to the guesses made in the OPs
original code, not the subsequent responses, most of which hit the nail on
the head.


ACK
Perhaps this acknowledgement puts you in a better temper?


It is not my temper that is the matter here. But JFYI, as you are so
concerned with my health, I have been quite calm when I was writing that
and I am now.
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
This is recommended in the FAQ only because all other books are worse.
So you acknowledge that, even by your demanding standards, it *is* the
best reference available? Or have I misunderstood?

(apologies for harking back to this - missed it first time)

Who's FAQ?


The FAQ of this newsgroup.
Why should I care?


Because you are not a fool?
And in any case, why does this have relevance?


Because it is the FAQ of _this_ newsgroup, written by and contributed to by
its accepted regulars, people whose knowledge about and understanding of
the subjects discussed probably exceeds yours by orders of magnitude?


You have no way of knowing what my level of understanding is. In
any case, a phrase such as "accepted regulars" is, to use one of your
favourite words "nonsense" when applied to a public, unmoderated forum.

You gain no special privileges due to the frequency (or pomposity) of your
posts.
I recommend it to the OP from my personal experience (and the ^^^^^^^
response of others I recommend it to).

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Pardon?

I recommend the book to other people. After they have bought the book and
digested its contents, they have a similarly high opinion.

Is your own personal experience of this book different?


Unfortunately, it is. Enough bad examples from it have been posted
here.


But have you *read* it? Every book may have errors or omissions.

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

http://www.oreilly.com/catalog/dhtmlref2/index.html
You could do worse, but this is bad enough. A book published four
years ago is certainly obsolete. The examples in the example chapter
prove that.


Ah, so you haven't read that one *either*?


Of course not. Why should I read or even buy a book that is obviously
obsolete and uses so many bad examples in just one chapter? Would you?

I did. Twice. There are trade-offs of course when a book is so old. I find
that its advantages far outweigh its drawbacks.

Once again, I am aware of the age of the book, and have had a steady
supply of others to compare it to. It is still without peer if you want
to *grok* DHTML/JS in a platform neutral manner, rather than firefight
a problem or hack something together.


That there is nothing better (which I seriously doubt) does not make it
any good.


And it does not disqualify it from being excellent for its intended
audience and purpose.

If there is something better, recommend it.

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


LOL, on what basis do you make *that* assertion, exactly?


Personal experience, including experience of postings in this newsgroup
of much higher quality.


Personal experience of *those* books? If you only have second
hand reports, or snippets of information posted here, how do you consider
that you have enough information to form an opinion?

Just about every question asked on here could be answered by referring the
OP to the language spec. or RFC, or some other "definitive" reference.
Chances are this will be of no use to the OP, as it will lack the context
to allow the information to be used in a timely way.

I await with interest your DHTML/XHTML/JS reference books. If they are as
good as you claim they are, I'll be happy to buy them and recommend them
to others. Until then...
BTW: Are you Kamal Sharma of Nugen.net, owner of mememe.com, or do you
have his explicit permission to use his second-level domain? If not,
you better stop this domain abuse at once.


You've Googled!


I have not, whois(1) sufficed. For some of us, the Internet is more
than the Web.


Pomposity simply doesn't do you justice. I use "Googled" in a colloquial
sense to describing a number of online search methods, cf. use of "Hoover"

For some of us, the language is more than the dictionary.

How sweet.


I am glad I could amuse you. You are easily impressed, yes?


Not usually. But impressed != amused. I'm more easily amused than
impressed.
But it's a fair point, I keep forgetting to reset my profile.

I'd much prefer to use my real name to tell you to piss off, should it
come to that.


I am sorry to say that your vocabulary does not form a non-empty
intersecting set with mine. [psf 2.13]


I can run up a few definitions if you like? But now that I have
a grip on your posting style, I don't think it will do either of us any
good.
I do not care much about your real name, at least not in this NetNews top-level hierarchy. I care about (misguided) network abuse, and you
should care about that, too.

Yes, fair point.
Happy now?


That was never the point. However, your From header is still not
acceptable as there is no .house top-level domain (yet). See also
<URL:http://giganews.com/legal/aup.html>


Don't worry; when the .house TLD becomes available, I'll be sure to
register it. Until then, I will remain resolutely unacceptable.


HTH

PointedEars


Feb 5 '06 #19

P: n/a
<rd********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
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.


You never clarified what the difference was between
"price per gallon" and "cost per gallon"
in your earlier post under
"Simple Calculation in Form - 3 textboxes - 1 function".
Feb 6 '06 #20

This discussion thread is closed

Replies have been disabled for this discussion.