[Javascript] global vars prob?!

Michael Borchers list at tridemail.de
Fri Feb 10 08:09:44 CST 2006


> Could we see some more work in progress of your code?
> We dont have the "/products_price_return/" function
> 
> Could you send us a minimal /html/ attached version of your code?
> 
> Michael Borchers escreveu:
> 
>> i dynamically create a textarea in a for() like this:
>>  
>> var offersNumRows = 2
>>  
>> var offersNumRowsAdded=4 (f.e.)
>>  
>>  for(o=0;o<offersNumRowsAdded;o++)
>>  { 
>>
>>       var numRow = offersNumRows + o;
>> ...
>>  
>>   var inputProductsDescription = document.createElement("textarea");
>>   inputProductsDescription.setAttribute("name","offers_products[" + 
>> numRow + "][products_description]");
>>   inputProductsDescription.setAttribute("id","offers_products[" + 
>> numRow + "][products_description]");  
>>   inputProductsDescription.setAttribute("cols",25);
>>   inputProductsDescription.setAttribute("rows",3); 
>>  
>>     HERE COMES THE TROUBLE MAKER:
>>   inputProductsDescription.onfocus=function() { 
>> products_price_return(numRow); }; 
>>  
>> ...
>>  
>> }
>>  
>> => NUMROW FINALLY IS 6
>>  
>> the for() and the rest of the script works well.
>> now when i call the on focus function for let's say for the 2nd 
>> created textarea
>> the numRow value for the products_price_return() function
>> always receives the nighest value of numRow from after the loop, in 
>> this case 6,
>> but not of the value it had when i created the element which should 
>> have been 2 in the 2nd created textarea.
>>  
>> how can i achieve my goal,
>> does anybody understand?

ok, hope this helps,
it's as minimal as possible and the dynamic creating works so far.
try addin 3 new rows, take the second created one and tab yourself through,
the price won't be shown in the right line:(

thanks so far!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20060210/afbaceef/attachment.htm>


More information about the Javascript mailing list