Reputation: 1275
I am using an HTML table and dynamically adding rows to it via Javascript. I am trying to pass the data from these rows to PHP / Laravel using input="hidden". Adding the rows to the HTML page seems to work fine, however I can't access the data when I call them from my PHP script. ($test doesn't seem to return anything) Any ideas why? Thanks!
HTML:
<table id='mytable'>
</table>
<input type='button' id='btnAddRow' value='Add' onclick='javaScript:addRow();'>
JS:
function addRow(){
var newRow = document.all("mytable").insertRow(-1);
var cell = newRow.insertCell(-1);
cell.innerHTML = "<input type='hidden' id='mydata' value='hello'>";
}
PHP:
$test = Input::get('mydata');
return $test;
Upvotes: 0
Views: 2133
Reputation: 16015
In order to pass data from the rows to PHP dynamically you need to make xmlhttprequests (ajax)
Upvotes: 0