Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] global vars prob
- From: junado at junado.com (Julien Nadeau)
- Subject: [Javascript] global vars prob
- Date: Wed Sep 28 13:27:37 2005
What happends is that you set your function to a litteral
"products_price_return(id);", therefore, when called, the function
reads the value from "id" rather than say, "products_price_return(5);".
You should look into settings it like this (although this is *evil*),
this might work:
inputProductsPrice.setAttribute("onfocus", "products_price_return
(" + id + ");");
Let me re-state that this is evil ;)
Julien Nadeau
junado@xxxxxxxxxx
Le 05-09-28 ? 10:19, Michael Borchers a ?crit :
> 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?
>
> _______________________________________________
> Javascript mailing list
> Javascript@xxxxxxxxxx
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.LaTech.edu/pipermail/javascript/attachments/20050928/939a0b98/attachment.html
- Follow-Ups:
- [Javascript] global vars prob
- From: Mike Dougherty
- [Javascript] global vars prob
- 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):