On May 23, 1:29 am, Gordon <[EMAIL PROTECTED]> wrote:
> I am writing a script that scans a list of items that each contain
> form fields and doing something based on the value of the field in
> each item.  I came up with the following code, which does seem to work
> as intended, but execution can take upwards of 500ms, which I feel is
> rather slow.
>
> var container = '#myElem';
>
> $(container.children ()).each (function ()

If myElem is the ID of the form, that will containt all the child
nodes, you will then iterate over all of them.  To get just the
controls with the same name:

  var controls = $('myElem').elements;

is likely much, much faster.  However, if there is only one control
with the name, controls will be a reference to that single control.
If there are two or more, controls will be a NodeList of all of them.
You might want to convert it to a jQuery array and then do each on
that:


> {
>         thisVal = parseInt ($('[EMAIL PROTECTED]"quantity"]', this).attr 
> ('value'),
> 10);

           var thisVal = +this.value;


Or something along those lines.

The unary + operator will do the conversion to number with less
bother, unless you  have a particular reason for using parseInt - have
you validated the input's value?

--
Rob

Reply via email to