I'm trying to insert multiple rows to a table based on an input value, i used this code but it doesn't work:
function AddRows() {
    var RowNumber = document.getElementById('quantite').value;
    var table = document.getElementById('articleTable');
    for (var i = 0; i < RowNumber; i++)
    {
        table.insertRow();
    };
}<div class="col-4">
    <div class="form-group">
        <label asp-for="Quantite" class="control-label"></label>
        <input asp-for="Quantite" class="form-control" id="quantite" />
        <span asp-validation-for="Quantite" class="text-danger"></span>
    </div>
</div>
<button type="button" class="btn btn-primary"  onclick="AddRows()">Add articles</button>
<table class="table table-bordered" id="articleTable" style="margin-top:10px;">
    <thead>
        <tr>
            <th>Numero de Serie</th>
            <th>Marque</th>
            <th>Etat</th>
        </tr>
    </thead>
    <tbody>
    </tbody>
 </table>So what's wrong in my code or is there any better way to add rows to html table based on an input value?
 
    