Voor mijn systeem m.b.t. urenregistratie ben ik een variabel aantal rijen aan het creëren. Nu wil ik deze rijen (in variërend aantal) dus wegschrijven in een SQL-database m.b.v. een post-form.
Om de rijen te creeëren gebruik ik de volgende code (script gevonden elders op internet):
<form method="post">
<table id="myTable">
<tr>
<td><input type="text" name="links"></td>
<td><input type="text" name="keywords"></td>
<td><input type="text" name="violationtype"></td>
</tr>
</table>
<input type="button" class="button" value="Add another line" onclick="addField();">
<script>
function addField (argument) {
var myTable = document.getElementById("myTable");
var currentIndex = myTable.rows.length;
var currentRow = myTable.insertRow(-1);
var linksBox = document.createElement("input");
linksBox.setAttribute("name", "links" + currentIndex);
var keywordsBox = document.createElement("input");
keywordsBox.setAttribute("name", "keywords" + currentIndex);
var violationsBox = document.createElement("input");
violationsBox.setAttribute("name", "violationtype" + currentIndex);
var addRowBox = document.createElement("input");
addRowBox.setAttribute("type", "button");
addRowBox.setAttribute("value", "Add another line");
addRowBox.setAttribute("onclick", "addField();");
addRowBox.setAttribute("class", "button");
var currentCell = currentRow.insertCell(-1);
currentCell.appendChild(linksBox);
currentCell = currentRow.insertCell(-1);
currentCell.appendChild(keywordsBox);
currentCell = currentRow.insertCell(-1);
currentCell.appendChild(violationsBox);
}
</script>
</form>
Zou iemand mij kunnen helpen met het maken van het PHP-stukje? alvast bedankt!
Tim