Add Textbox inside an HTML table with Jquery

Asked

Viewed 331 times

3

I have the Jquery Script below that searches a Material and returns a Json list of that materials, I need to put this data in a table and put a field for the user to enter the amount of these materials, even putting in the Script so that the textbox gets the size 2 it remains in normal size. Does anyone know how to do that?

<script type="text/javascript">
    $('#pesquisar').click(function () {
        $.ajax({
            url: "/RCM/ListarMateriais",
            type: "POST",
            data: { nome: $('#NomeMaterial').val() },
            datatype: 'json',
            success: function (data) {
                $.each(data, function (I, item) {
                    $('#tbl').append("<tr><td>" + item.Nome + "</td><td>" + item.TD + "</td><td>" + item.Unidade +
                        "</td><td> <input type=\"text\" name=\"qtd\" size=\"2\" /> <input id=\"btAdd\" type=\"button\" value=\"Adicionar\" /> </td>")
                })
            }
        });
    });
</script>

1 answer

1


I think you mean width, nay size

<script type="text/javascript">
    $('#pesquisar').click(function () {
        $.ajax({
            url: "/RCM/ListarMateriais",
            type: "POST",
            data: { nome: $('#NomeMaterial').val() },
            datatype: 'json',
            success: function (data) {
                $.each(data, function (I, item) {
                    $('#tbl').append("<tr><td>" + item.Nome + "</td><td>" + item.TD + "</td><td>" + item.Unidade +
                        "</td><td> <input type=\"text\" name=\"qtd\" style=\"width: 50px;\" /> <input id=\"btAdd\" type=\"button\" value=\"Adicionar\" /> </td>")
                })
            }
        });
    });
</script>
  • So it worked, thank you very much Gypsy, helping me once again.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.