[Javascript] global vars prob

Mike Dougherty mdougherty at pbp.com
Wed Sep 28 13:33:50 CDT 2005


Sorry, after reading Julien's reply I realized I did not understand the original question

On Wed, 28 Sep 2005 13:47:54 -0400
  Julien Nadeau <junado at junado.com> wrote:
> 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 at junado.com
> 
> 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 at LaTech.edu
>> https://lists.LaTech.edu/mailman/listinfo/javascript
>>
> 
> 
> 
> 
> __________________________________________________________
> This message was scanned by ATX
> 2:28:00 PM ET - 9/28/2005




More information about the Javascript mailing list