2
This is the table has the fields the goal is to click the edit button and while clicking the instruction jquery that I put on top will fill in the fields automatically referring to the line that was clicked
Here’s the thing I want to take the table records and put them in a modal input text and I used the next code (It’s working but only for <input type="text">
but for textarea
and combobox
doesn’t work and that’s what I want)
<script>
$('body').on("click", ".edit", function() {
$('#alterar_ID').val($(this).parents('tr').find('td').eq(0).text());
$('#alterar_si').val($(this).parents('tr').find('td').eq(0).text());
$('#alterar_nome').val($(this).parents('tr').find('td').eq(1).text());
$('#alterar_data').val($(this).parents('tr').find('td').eq(2).text());
$('#alterar_duracao').val($(this).parents('tr').find('td').eq(3).text());
$('#alterar_tipo').val($(this).parents('tr').find('td').eq(4).text());
$('#alterar_relatorio').val($(this).parents('tr').find('td').eq(5).text());
});
</script>
That is, by clicking a button in the table it will fetch the values corresponding to the indexes and put them in the modal inputs. My question is as follows and if I want to put in a textarea or leave a combobox?
For both the same way works, so much so that if you do
$('#alterar_nome').val()
You will get the value of this field. You can use the.va()
normally– Erlon Charles
could post html code or your doubt MCVE?
– Karl Zillner
is to place the combobox with the string equal to that of the table or in the case of the client name field when editing leave selected the client name respective to the client name of the line that was pressed the button
– Shider
Let’s go continue this discussion in chat.
– Sam