How to pass a javascript variable to PHP -


im creating dynamic form button called "add more rows" when clicked javascript function creates new row of textboxes appropriate id.

the problem is, how pass counter variable javascript function next php page nows how many rows of textboxes receive $_post.

ive got javascript function i'm missing data rows creates itself.

any ideas?

thanks

this js function

window.onload=function() {  inp=document.getelementsbytagname('input'); for(c=0;c<inp.length;c++)      {         if(inp[c].value=='add')          {            inp[c].onclick=function()              {                 n=15;                 x=document.createelement('input');                x.setattribute('rows',1);                x.setattribute('cols',20);                x.name='time'+n;                document.getelementbyid('txtara').appendchild(x)                x=document.createelement('input');                x.setattribute('rows',1);                x.setattribute('cols',20);                x.name='event'+n;                document.getelementbyid('txtara').appendchild(x)                x=document.createelement('input');                x.setattribute('rows',1);                x.setattribute('cols',20);                x.name='supplies'+n;                document.getelementbyid('txtara').appendchild(x)              var sel = document.createelement('select');            y = document.createelement('option');         y.value = 'yes';         y.name = 'success' + n;         y.innerhtml = y.value;          x = document.createelement('option');         x.value = 'no';         x.name = 'success' + n;         x.innerhtml = x.value;           sel.appendchild(y);         sel.appendchild(x);           document.getelementbyid('txtara').appendchild(sel);         document.getelementbyid('txtara').appendchild(sel);         document.getelementbyid('txtara').appendchild(sel);                  x=document.createelement('input');                x.setattribute('rows',1);                x.setattribute('cols',20);                x.name='comment'+n;                document.getelementbyid('txtara').appendchild(x)                 document.getelementbyid ('txtara').innerhtml += '<br>';           n++;             }          }      }     //--> } 

you should add <input type="hidden" name="num_rows" value="0"> form , update value row count when form submitted.


Comments

Popular posts from this blog

sql - text truncated using perl DBI insert -

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

php - Pass object by reference or value -