[Javascript] global vars prob?!
Michael Borchers
list at tridemail.de
Fri Feb 10 07:04:36 CST 2006
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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20060210/624497bc/attachment.htm>
More information about the Javascript
mailing list