0

Using javascript have added rows at run time.Have stored name of each column of a row in multidimentional array.Now I need to access this array on a PHP page.How to POST this array on PHP page?The below code is regarding the generating multidimentional array.

var j=0; function addRow(tableID) { j++;

 var table=document.getElementById(tableID);
 var rowCount=table.rows.length;
 var row=table.insertRow(rowCount);
 var colCount=table.rows[0].cells.length;

alert(rowCount)

 for(var i=0;i<colCount;i++)
     {


 var newcell=row.insertCell(i);
 newcell.innerHTML=table.rows[0].cells[i].innerHTML;
 switch(newcell.childNodes[0].type)
     {case"text":newcell.childNodes[0].value="";
    // alert(2);
       var value = "" + "coll"+ j + i;

      newcell.setAttribute("name",value);
      MultiArray = new Array(rowCount)
      MultiArray [rowCount] = new Array(7)
     //var name  = newcell.getAttribute('name')

     MultiArray[rowCount][i]  = newcell.getAttribute('name')
     alert("hi")
    //alert(MultiArray[rowCount][i]);



     break;
     case"checkbox":newcell.childNodes[0].checked=false;
     break;
     case"Remark":newcell.childNodes[0].textarea=0;
     break;
     }}}
3
  • 3
    Serialise as JSON and submit as an Ajax request. Commented Jan 7, 2015 at 12:06
  • possible duplicate of JS <---> PHP communication Commented Jan 7, 2015 at 12:09
  • 2
    AJAX may well not be required here. Sending the array as JSON via a POST from the <form> submission would be enough in many cases. This could be done by listening for the submit event. Commented Jan 7, 2015 at 12:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.