Javascript error when creating form elements -


error:

uncaught exception: [exception... "component returned failure code: 0x80004003 (ns_error_invalid_pointer) [nsidomhtmlselectelement.appendchild]" nsresult: "0x80004003 (ns_error_invalid_pointer)" location: "js frame :: http://localhost/midas/index.php/submit/displayform :: :: line 104" data: no]

the code meant create:

textboxt - textbox - textbox - pulldown - textbox

here code below

<script type="text/javascript"> <!--   var ta=new array();   var n=15; window.onload=function() {    inp=document.getelementsbytagname('input'); for(c=0;c<inp.length;c++)      {         if(inp[c].value=='add')          {            inp[c].onclick=function()              {                 var ta = [];                 var n = 15;                 ta[n]=document.createelement('input');                ta[n].setattribute('rows',1);                ta[n].setattribute('cols',20);                ta[n].name='time'+n;                document.getelementbyid('txtara').appendchild(ta[n])                ta[n]=document.createelement('input');                ta[n].setattribute('rows',1);                ta[n].setattribute('cols',20);                ta[n].name='event'+n;                document.getelementbyid('txtara').appendchild(ta[n])                ta[n]=document.createelement('input');                ta[n].setattribute('rows',1);                ta[n].setattribute('cols',20);                ta[n].name='supplies'+n;                document.getelementbyid('txtara').appendchild(ta[n])                  var sel = document.createelement('select');                    ta[n]=document.createelement('option');                 ta[n].value = 'yes';                 ta[n].name='success'+n;                 ta[n].innerhtml = ta[n].value;                 n++;                 ta[n]=document.createelement('option');                 ta[n].value = 'no';                 ta[n].name='success'+n;                 ta[n].innerhtml = ta[n].value;                 n++;                  sel.appendchild(ta[0]);                 sel.appendchild(ta[1]);                   document.getelementbyid('txtara').appendchild(sel);                   document.getelementbyid('here').appendchild(sel);                document.getelementbyid('txtara').appendchild(ta[n])                n++;             }          }      } } //--> </script> 

your code creating nodes , storing them in ta[15] , ta[16], you're inserting nodes ta[0] , ta[1] dom, don't exist.

do var n = 0; instead of n = 15.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

c# - SharpSVN - How to get the previous revision? -

php cli reading files and how to fix it? -