On Dec 4, 1:20 am, Wizzud <[EMAIL PROTECTED]> wrote: > That would be because your $(':input', this) selector is selecting > *every* input field in your form and adding it to your inputs array. > One solution is to put a test in your each() function to see if the > field is a checkbox or radio, and if it is, only add it to your inputs > array if it's checked. Is there a simple way to do that?
> On Dec 3, 11:24 am,e2e<[EMAIL PROTECTED]> wrote: > > > Hi, > > > I use this function to submit my post requests. But now I have a > > problem with radio buttons and checkboxes. It sends all button values > > to server, so the last radio buttons' (even it's not checked) value > > passes as value. checkboxes are same, even it's not checked, it sends > > checked value. > > > $("form#profile_form").submit(function() { > > $("#users_profile h1").after('<div class="loading"></div>'); > > $("#users_profile .errors").remove() > > var inputs = []; > > $(':input', this).each(function() { > > inputs.push(this.name + '=' + unescape(this.value)); > > }); > > $.ajax({ > > type : "POST", > > data : inputs.join('&'), > > url : "tasks.php?task=updateprofile", > > success : function(msg) { > > $("#users_profile .loading").remove(); > > if(msg == "ok") { > > $("#profile_form").remove(); > > $("#users_profile h1").after('<div > > class="message m_info">Profile > > updated!</div>'); > > } else { > > $("#users_profile h1").after(msg); > > } > > } > > }); > > return false; > > });