Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #15555 > unrolled thread
| Started by | justaguy <lichunshen84@gmail.com> |
|---|---|
| First post | 2012-08-25 06:18 -0700 |
| Last post | 2012-08-25 12:44 -0700 |
| Articles | 4 on this page of 24 — 10 participants |
Back to article view | Back to comp.lang.javascript
Sum of several fields using parseInt differs from that of using a calculator justaguy <lichunshen84@gmail.com> - 2012-08-25 06:18 -0700
Re: Sum of several fields using parseInt differs from that of using a calculator Martin Honnen <mahotrash@yahoo.de> - 2012-08-25 15:39 +0200
Re: Sum of several fields using parseInt differs from that of using a calculator justaguy <lichunshen84@gmail.com> - 2012-08-25 09:27 -0700
Re: Sum of several fields using parseInt differs from that of using a calculator Denis McMahon <denismfmcmahon@gmail.com> - 2012-08-25 18:53 +0000
Re: Sum of several fields using parseInt differs from that of using a calculator SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-26 11:13 +0200
Re: Sum of several fields using parseInt differs from that of using a calculator Dr J R Stockton <reply1234@merlyn.demon.co.uk.invalid> - 2012-08-26 18:54 +0100
Re: Sum of several fields using parseInt differs from that of using a calculator SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-25 20:39 +0200
Re: Sum of several fields using parseInt differs from that of using a calculator justaguy <lichunshen84@gmail.com> - 2012-08-25 14:07 -0700
Re: Sum of several fields using parseInt differs from that of using a calculator Martin Honnen <mahotrash@yahoo.de> - 2012-08-26 11:23 +0200
Re: Sum of several fields using parseInt differs from that of using a calculator SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-26 11:27 +0200
Re: Sum of several fields using parseInt differs from that of using a calculator justaguy <lichunshen84@gmail.com> - 2012-08-26 06:26 -0700
Re: Sum of several fields using parseInt differs from that of using a calculator justaguy <lichunshen84@gmail.com> - 2012-08-26 08:48 -0700
Re: Sum of several fields using parseInt differs from that of using a calculator SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-26 20:55 +0200
Re: Sum of several fields using parseInt differs from that of using a calculator Denis McMahon <denismfmcmahon@gmail.com> - 2012-08-26 20:50 +0000
Re: Sum of several fields using parseInt differs from that of using a calculator "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-08-26 21:30 +0000
Re: Sum of several fields using parseInt differs from that of using a calculator Denis McMahon <denismfmcmahon@gmail.com> - 2012-08-26 22:29 +0000
Re: Sum of several fields using parseInt differs from that of using a calculator SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-26 23:32 +0200
Re: Sum of several fields using parseInt differs from that of using a calculator Denis McMahon <denismfmcmahon@gmail.com> - 2012-08-26 22:39 +0000
Re: Sum of several fields using parseInt differs from that of using a calculator SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-08-27 04:23 +0200
Re: Sum of several fields using parseInt differs from that of using a calculator Martin Leese <please@see.Web.for.e-mail.INVALID> - 2012-08-27 11:09 -0600
Re: Sum of several fields using parseInt differs from that of using a calculator Stefan Weiss <krewecherl@gmail.com> - 2012-08-28 02:14 +0200
Re: Sum of several fields using parseInt differs from that of using a calculator Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-28 14:53 +0200
Re: Sum of several fields using parseInt differs from that of using a calculator Martin Leese <please@see.Web.for.e-mail.INVALID> - 2012-08-28 11:29 -0600
Re: Sum of several fields using parseInt differs from that of using a calculator "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-08-25 12:44 -0700
Page 2 of 2 — ← Prev page 1 [2]
| From | Stefan Weiss <krewecherl@gmail.com> |
|---|---|
| Date | 2012-08-28 02:14 +0200 |
| Message-ID | <k1h2gf$2o2$1@news.albasani.net> |
| In reply to | #15589 |
On 2012-08-27 19:09, Martin Leese wrote: > Denis McMahon wrote: > ... >> 15) In my opinion, It's a good habit to get into the practice of >> specifying attributes such as nowrap, readonly, selected in the form >> attr="attr", ie readonly="readonly", selected="selected", nowrap="nowrap", >> even if you are only using html 4.01. > > Thanks for this. The other advice was good > to, but this was one of which I hadn't > thought. (It even validates at 4.01 Strict.) Just be aware that this advice is just an opinion. Some people do it, some websites (like W3Schools, unsurprisingly) think it's the only way. It may not do any harm, but personally I can't see any advantage of <option selected="selected"> over <option selected>. If you're using HTML (as opposed to XHTML), value-less attributes are perfectly fine. By the way, the "nowrap" attribute shouldn't be used anymore at all. It was deprecated in HTML 4.01 and removed in HTML 5. - stefan
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2012-08-28 14:53 +0200 |
| Message-ID | <1425526.EZpXKcVxos@PointedEars.de> |
| In reply to | #15591 |
Stefan Weiss wrote: > On 2012-08-27 19:09, Martin Leese wrote: >> Denis McMahon wrote: >> ... >>> 15) In my opinion, It's a good habit to get into the practice of >>> specifying attributes such as nowrap, readonly, selected in the form >>> attr="attr", ie readonly="readonly", selected="selected", >>> nowrap="nowrap", even if you are only using html 4.01. >> >> Thanks for this. The other advice was good >> to, but this was one of which I hadn't >> thought. (It even validates at 4.01 Strict.) > > Just be aware that this advice is just an opinion. No, it is just bad advice: <http://www.w3.org/TR/html401/appendix/notes.html#h-B.3.4> > Some people do it, some websites (like W3Schools, unsurprisingly) think > it's the only way. $DEITY protect us from the utter nonsense spread readily by W3Schools. The W3C should sue them for abusing their name. PointedEars -- > If you get a bunch of authors […] that state the same "best practices" > in any programming language, then you can bet who is wrong or right... Not with javascript. Nonsense propagates like wildfire in this field. -- Richard Cornford, comp.lang.javascript, 2011-11-14
[toc] | [prev] | [next] | [standalone]
| From | Martin Leese <please@see.Web.for.e-mail.INVALID> |
|---|---|
| Date | 2012-08-28 11:29 -0600 |
| Message-ID | <k1iv5h$6h5$1@dont-email.me> |
| In reply to | #15592 |
Thomas 'PointedEars' Lahn wrote: > Stefan Weiss wrote: >> On 2012-08-27 19:09, Martin Leese wrote: >>> Denis McMahon wrote: >>> ... >>>> 15) In my opinion, It's a good habit to get into the practice of >>>> specifying attributes such as nowrap, readonly, selected in the form >>>> attr="attr", ie readonly="readonly", selected="selected", >>>> nowrap="nowrap", even if you are only using html 4.01. >>> Thanks for this. The other advice was good >>> to, but this was one of which I hadn't >>> thought. (It even validates at 4.01 Strict.) >> Just be aware that this advice is just an opinion. > > No, it is just bad advice: > <http://www.w3.org/TR/html401/appendix/notes.html#h-B.3.4> This note states, "... many user agents only recognize the minimized form of boolean attributes and not the full form." However, the document was published in December 1999, over 12 years ago. This is now off-topic for this newsgroup, but does anybody know which browser versions these were? -- Regards, Martin Leese E-mail: please@see.Web.for.e-mail.INVALID Web: http://members.tripod.com/martin_leese/
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2012-08-25 12:44 -0700 |
| Message-ID | <519a887d-a1ea-46fe-9449-e3a66e3d5988@googlegroups.com> |
| In reply to | #15555 |
On Saturday, August 25, 2012 8:18:55 AM UTC-5, justaguy wrote:
> Hi,
>
>
>
> I have several form fields (line items) that I need to add up to a
>
> total, using parseInt(fieldName.value,10) to add them up
>
> for the following values:
>
> 2992
>
>
>
> 450
>
>
>
> 1015.75
>
>
>
> 90
>
>
>
> 1200
>
>
>
> returns 5837, however, using a calculator it returns 5747.75.
>
> How come? Also, I don't know if the number would have decimal
>
> beforehand. How can we use parseInt or other similar javascript
>
> function to perform such calculation?
>
>
>
> Thanks in advance.
['2992','450','1015.75','90','1200'].reduceRight(function(a,b){
return Number(a) + Number(b);
},0);
/*
5747.75
*/
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.javascript
csiph-web