I have a form generated with the answer of an ajax call to php page communicating with my database.
When I click on the submit button I gather through Jquery the content of the different inputs of the form (text,checkbox,textarea,...) in simple arrays to send them back to the database.
Now I want to reset the form after the submission. I failed to use myForm.reset() to clear everything (it did nothing) even with all the methods I found on stackoverflow and the Internet in general. So I decided to code the clear process myself.
To the main problem : I gather the value of the checked checkboxes with :
var complement0=[];
complement0.push($("input[name=foo]:checked").map(function() {
return this.value;
}).get());
And then try to uncheck the checkboxes. Here are the ways I tried to do it without success :
$("input[name=foo]:checked").each(function() {
$(this).removeAttr('checked');
});
$("input[name=foo]:checked").map(function() {
return this;
}).removeAttr('checked');
$("input[name=prsFmtLng]:checked").attr('checked',false);
$("input[name=prsFmtLng]:checked").removeAttr('checked');
Since it looks like it is simple when other people talk about this, either I don't understand what I am doing or I am just missing something. Any help is welcomed.
Aucun commentaire:
Enregistrer un commentaire