<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">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);".<DIV><BR class="khtml-block-placeholder"></DIV><DIV>You should look into settings it like this (although this is *evil*), this might work:</DIV><DIV>    inputProductsPrice.setAttribute("onfocus", "products_price_return(" + id + ");");</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Let me re-state that this is evil ;)<BR><DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">Julien Nadeau</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica"><A href="mailto:junado@junado.com">junado@junado.com</A></FONT></DIV>  </DIV><BR><DIV><DIV>Le 05-09-28 à 10:19, Michael Borchers a écrit :</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005">i am creating new elements within for()</SPAN></FONT></DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005">with a starting var named "id"</SPAN></FONT></DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005"></SPAN></FONT> </DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005"> id = ordersNumRows;</SPAN></FONT></DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"></FONT> </DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005"> for(o=0;o&lt;ordersNumRowsAdded;o++)<BR> {</SPAN></FONT></DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005">...</SPAN></FONT></DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005">  inputProductsPrice.setAttribute("id","products_id[" + id + "][products_price]");</SPAN></FONT></DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005">  inputProductsPrice.onfocus=function() { products_price_return(id); };</SPAN></FONT></DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005">...</SPAN></FONT></DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005">id++;</SPAN></FONT></DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005">}</SPAN></FONT></DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005"></SPAN></FONT> </DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005">the shown ID in the attribute works fine =&gt; 0, 1, 2, ... X (let's say 10)</SPAN></FONT></DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005"></SPAN></FONT> </DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005">but when the function is called, the id always is the highest value at the end of for, f.e. 10</SPAN></FONT></DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005"></SPAN></FONT> </DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005">how do these globals work, do i have to add them with a " + " or similar?</SPAN></FONT></DIV> <DIV><FONT face="Trebuchet MS" color="#0000ff" size="2"><SPAN class="804061614-28092005"></SPAN></FONT> </DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Javascript mailing list</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="mailto:Javascript@LaTech.edu">Javascript@LaTech.edu</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="https://lists.LaTech.edu/mailman/listinfo/javascript">https://lists.LaTech.edu/mailman/listinfo/javascript</A></DIV> <BR class="Apple-interchange-newline"></BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>