Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

132
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda