Add TextBox inside an HTML table with JQuery

3

I have the JQuery Script below which searches a Material and returns a list in Json of this materials, I need to put this data in a table and put a field for the user to enter the quantity of these materials, even putting in the Script so that the textbox is the size 2 it continues at normal size. Anyone know how I can do this?

<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>
    
asked by anonymous 21.08.2014 / 21:16

1 answer

1

I think you meant width , not 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>
    
21.08.2014 / 21:52