I need help. I am able to add another row to the table on my html webpage but only one row is saved into the database after I input the data. I am not sure what I am doing wrong. Can someone please help or guide me into the right direction. I need it to be javascript. As simple as possible. Thank you My database is called logworkout
<script>
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var element1 = document.createElement("input");
element1.type = "text";
element1.name = "routine";
element1.placeholder = "routine";
cell2.appendChild(element1);
var cell3 = row.insertCell(2);
var element2 = document.createElement("input");
element2.type = "text";
element2.name = "repetitions";
element2.placeholder = "repetitions";
cell3.appendChild(element2);
var cell4 = row.insertCell(3);
var element3 = document.createElement("input");
element3.type = "text";
element3.name = "sets";
element3.placeholder = "sets";
cell4.appendChild(element3);
}
</script>
<table id="dataTable" width="350px" border="1">
<tr>
<td><label for="exercise">Exercise:</label></td>
<td><input type="text" placeholder="routine" name="routine" id ="routine" ></td>
<td><input type="text" placeholder="repetitions" name="repetitions" id ="repetitions" ></td>
<td><input type="text" placeholder="sets" name="sets" id ="sets" ></td>
</div>
</tr>
</table>
<input type="button" value="Add Row" onclick="addRow('dataTable')" />
<input type="submit" name="submit" value="Submit" id="submit">
</form>
key:valueformat and then on your submit call, pass that array indataattribute. Hope that helps