-1
Good afternoon, this is my first post, I would like the help of vcs, I have a select option that searches the data in the bd, just after this I have a button where I open a modal window to include more options to this select if you need, with this I do a cadre in the bd without refreshing the page, this because I already have items inserted in the other inputs, what I need is that after the registration this select option is updated without the page re-fres. follows the code.
<select id="location" name="reup" >
<option value="">item</option>
<?php aqui vem os demais option com a busca no bd ?>
</select>
jquery:
$('#insert').click(function(e){
e.preventDefault();
var nomer = $('#nomer').val();
.....
var obsr = $('#obsr').val();
$.post('insreu.php', {
nomer:nomer,
.....
obsr:obsr
}, function(resposta){
if(resposta == 1){
$('input, textarea').val('');
$('#reup').append(e);
alert('Cadastrado com sucesso.');
}else {
alert(resposta);
}
});
});
Thanks for your help.
good afternoon, I still have the problem, I register without refresh on the page, but I can not refresh in select
– Gerson
Did an error appear in the console? You failed is too broad
– Pedro Henrique
I just got it right, I put an id in the select div that is outside the modal window, at the end I had the div updated so that I did the Insert, my problem now is another, I have 5 selects making that I have 5 modal windows in this form, so the first one works without problems , but I can not insert in the comics the others, the modals work but the Inserts do not, I am following the same logic, and of course each modal with its distinct identification.
– Gerson
was like this : obsr }). done(Function(href){ $("#updated"). load( href +" #updated"); }); $('#modalreu'). modal('Hide'); }); already got the rest right, lack of attention, had forgotten the id’s in the inputs
– Gerson