Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
creating dynamic table on page load shows empty first row

I have created a dynamic table. On button click, the values are added to the table from the form. But my table is showing first empty row initially. Only after that first empty row of the table, dynamic rows are created. How to remove this first empty row? Please see the attached image.

@*============ form content ================*@
    <div class="container col-md-12">
        <div>
            <div class="col-md-4">
                @Html.DropDownList("MedicineId", null, htmlAttributes: new { @class = "form-control ddrel" })
            </div>
            <div class="col-md-6">
                @Html.EditorFor(model => model.Amount, new { htmlAttributes = new { @class = "form-control iamt" } })
            </div>
            <div class="col-md-2">
                <button type="button" class="button button3 btn-default btn-sm">
                    <span class="glyphicon glyphicon-plus"></span>
                </button>
            </div>
        </div>
    </div>
@*============= table ==============================*@
<table class="table table-condensed table-bordered"  id="selected_units">
    <thead>
        <tr>
            <th>Medicine</th>
            <th>Amount</th>
            <th>Delete</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </tbody>
</table>
@*===============================================*@
<script type="text/javascript">
    $('.button').click(function () {
        var reltype = $('.ddrel option:selected').text();
        var relname = $('.iamt').val();
    var newrow = '<tr><td>' + reltype + '</td><td>' + relname + '</td><td><input type="button" value="Delete" onclick="Remove(this)" /></td></tr>';
    $('#selected_units tr:last').after(newrow);
});

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!