2009/7/4 Satyam <satyam@...>
Douglas Crockford always says 'eval is evil'. JSLint will scream at you
so I would assume you didn't pass it by JSLint or didn't fix all its
diagnostics. Please do, it really spares you lots of trouble. Avoid
such constructs, there is hardly any that cannot be expressed some other
way, like:rec[oReg[0].childNodes[i].nodeName] = oReg[0].childNodes[i].textContent;
eval("rec." + oReg[0].childNodes[i].nodeName + "='" +
oReg[0].childNodes[i].textContent + "'");
I can't say right away what's wrong with your code. I can only suggest
you use more intermediate variables to hold references that you will use
time and time again, like:
myDataTable.getSelectedRows()[0]
or
oReg[0].childNodes
And then, there is nothing more than single-stepping through that
segment of code checking those intermediate values to see if they make
sense, which they look Ok, but there is obviously something missing.
Satyam
Daniel escribió:> 2009/7/3 Daniel <ikaro75@... <mailto:ikaro75@...>>
>
>
> Hello,
>
> it's strange sometimes it the row gets updated with "undefined", i
> think it has to be with XML load time. What can I do in order to fix it?
>
> The example ishttp://investigacion.ilce.edu.mx/inventario/inventarios.html
>> 2009/7/3 ikaro751 <ikaro75@... <mailto:ikaro75@...>>
>
> I solved it with this code:
>
> oReg=o.responseXML.getElementsByTagName("registro");
> var rec =
> myDataTable.getRecordSet().getRecord(myDataTable.getSelectedRows()[0]).getData();
>
>
> for (i=0;i<oReg[0].childNodes.length;i++) {
> eval("rec." + oReg[0].childNodes[i].nodeName + "='" +
> oReg[0].childNodes[i].textContent + "'");
> }
> myDataTable.updateRow(myDataTable.getSelectedRows()[0],rec );
>
>
>
>
> Hello, I'm tring to update the row selected in a datatable;
> I have the new values in a XML node; the number of nodes in
> the responseXML is the same as the recordset in the datatable;
> how do I update the row?
>
> This is how I'm trying to do it, but I get a invalid assigment
> left-hand side.
>
> oReg=o.responseXML.getElementsByTagName("registro");
> for (i=0;i<oReg[0].childNodes.length;i++) {
> myDataTable.getRecordSet().getRecord(myDataTable.getSelectedRows()[0]).setData(i)=oReg[0].childNodes[i].textContent;
> }
>
> Thanks for your help!
>
>
>
>
>
>
> ----------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.375 / Virus Database: 270.13.3/2216 - Release Date: 07/03/09 05:53:00
>
>