Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] global vars prob
- From: mdougherty at pbp.com (Mike Dougherty)
- Subject: [Javascript] global vars prob
- Date: Wed Sep 28 10:57:48 2005
What value do you expect the variable to hold after you have incremented it to 10?
if you are initializing the variable to "ordersNumRows" (which is zero) then re-incrementing it to
ten, it will always be 10 at the end of the for() iteration.
you may want to use "var id = ..." inside your procedures so you do not have scoping issues
between local/procedure variables and global or higher scoped variables
On Wed, 28 Sep 2005 16:19:05 +0200
"Michael Borchers" <borchers@xxxxxxxxx> wrote:
> i am creating new elements within for()
> with a starting var named "id"
>
> id = ordersNumRows;
>
> for(o=0;o<ordersNumRowsAdded;o++)
> {
> ...
> inputProductsPrice.setAttribute("id","products_id[" + id + "][products_price]");
> inputProductsPrice.onfocus=function() { products_price_return(id); };
> ...
> id++;
> }
>
> the shown ID in the attribute works fine => 0, 1, 2, ... X (let's say 10)
>
> but when the function is called, the id always is the highest value at the end of for, f.e. 10
>
> how do these globals work, do i have to add them with a " + " or similar?
>
>
>
>
> __________________________________________________________
> This message was scanned by ATX
> 10:18:17 AM ET - 9/28/2005
- References:
- [Javascript] global vars prob
- From: Michael Borchers
- [Javascript] global vars prob
- Prev by Date: [Javascript] global vars prob
- Next by Date: [Javascript] global vars prob
- Previous by thread: [Javascript] global vars prob
- Next by thread: [Javascript] global vars prob
- Index(es):