c# – Add TextBox inside an HTML table with JQuery

Question:

I have the JQuery Script below that searches for a Material and returns a list in Json of these materials, I need to put this data in a table and put a field for the user to type the amount of these materials, even putting it in the Script so that the textbox has size 2 it's still normal size. Does 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>

Answer:

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>
Scroll to Top