Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #15579

Re: Sum of several fields using parseInt differs from that of using a calculator

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: Sum of several fields using parseInt differs from that of using a calculator
Date 2012-08-26 20:50 +0000
Organization A noiseless patient Spider
Message-ID <k1e26f$r6g$1@dont-email.me> (permalink)
References <24572a83-a8c2-4e00-99b2-383206781c09@d13g2000yqm.googlegroups.com> <50391bc8$0$6183$ba4acef3@reader.news.orange.fr> <5c08b4d4-5162-4580-9c9e-d23937e046e2@z17g2000yqk.googlegroups.com> <5039ec17$0$6192$ba4acef3@reader.news.orange.fr> <1e52efa2-bcfe-45f6-a005-608614428fbb@k3g2000yqo.googlegroups.com>

Show all headers | View raw


On Sun, 26 Aug 2012 06:26:42 -0700, justaguy wrote:

> Back to what a poster mentioned earlier about posting the entire
> rendered HTML form here.  Here we go.  We still have a problem when a
> user goes back to change a quantity, then subtotal changes, total
> changes, and we don't know if the quantity is increased or decreased.
> Please copy/paste the following FORM to take a look.  Many thanks.

The html is broken in several ways:

1) You use <br/>, this is normally written <br /> (note space before "/") 
(see also 13)
2) You haven't closed your "input" elements. If you are using <br /> then 
your input elements also need to be terminated with " />" and not 
">" (see also 13)
3) You can't stick input elements at arbitrary points in a table element, 
even hidden input elements must be contained inside a <td></td> tag pair 
if you wish to use them inside a table.
4) You have unclosed options (see also 13).
5) You have unclosed selects.
6) You have unescaped character entities.
7) You have more <table> than </table> tags. Look at the nested table 
surrounding the "notes" textarea toward the bottom of the page.
8) You may be confusing the "size" attribute of the input element with a 
non standard attribute that you have called "width".
9) You have empty option elements.
10) "lightblue" is not a recognised color for the "bgcolor" attribute of 
the body element.
11) True is not a valid value for the "nowrap" attribute to the td 
element.
12) The document actually appears, when corrected, to be HTML 4.01 
transitional, so doesn't need closing "/ " of br or input elements, or of 
option elements. You should choose a markup for the page and stick to it, 
not use a mix of xhtml and html markup in a single page. Pick a doctype, 
declare it, stick to it, validate against it.
13) Your form is very wide - I assume you don't expect your customers to 
use tablets / mobile devices. You may wish to use size attributes on some 
of the columns in the table.
14) Consider css for styling.
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.

16) Debugging javascript is easier if you write the functions out in a 
structured manner in a script section in the document head.
17) This also makes it possible for the functions to call each other, 
something that is not possible when attaching functions directly to 
actions.
18) You could then use a single function for updating the row totals 
every time any of the quantities is changed. You could also call the 
"totals" function from this single row function to apply the discount and 
update the totals.

See http://www.sined.co.uk/tmp/jag1.htm for an example of how it could be 
improved, and note that there may be many ways to improve on what I have 
done so far.

Note that I have reduced the code to the minimum required to show an 
example of how I would write the javascript to calculate the line and 
total prices, so it is a much simpler page than the one you posted.

Rgds

Denis McMahon

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web