The thing here is adding table rows by inputting value on the text box. i.e. If I input 2 on text box and click on submit, it will add two table rows. I've been searching for solutions but I can't seem to find an answer, well for now.
<form align="center" method="GET">
<input type="text" name="users" id="user_id"><br>
<input type="submit" id="mysubmit" value="Submit" onClick="addMoreRows()">
</form>
<table id="tbl_id" style="text-align:center" align="center" valign:"top">
<thead>
<tr>
<th>Name</th>
<th>Score</th>
<th>Points</th>
<th>Total</th>
</tr>
</thead>
</table>
<script type="text/javascript">
var rowsAdd = document.getElementById('tbl_id').insertRow();
var rowsAdded;
function addMoreRows(){
rowsAdded = document.getElementById('user_id').value();
for(int x=0; x<rowsAdded; x++){
var newCell = newRow.insertCell();
newCell.innerHTML="<tr><td><input type='text' name='user_name'></td></tr>";
newCell = newRow.insertCell();
newCell.innerHTML="<tr><td><input type='text' name='score'></td></tr>";
newCell = newRow.insertCell();
newCell.innerHTML="<tr><td><input type='text' name='points'></td></tr>";
newCell = newRow.insertCell();
newCell.innerHTML="<tr><td><input type='text' name='total'></td></tr>";
}
Where did I go wrong? Or all of the code are totally wrong?
for(int x=0? Tryfor (var x=0