I am trying to get all input text boxes, radio groups, checkboxes, etc. I'm having problems getting the selected radio values and checkboxes, I can’t figure it out.
I can get the text fields, but I can not get the "selected" in the right place. At the moment, it just gets the first value for the radio / flags, not the selected value.
$('#form_1 input').each(function(key)
formData += '&'+$('#'+this.id).attr('name')+'='+$('#'+this.id).val();
});
thank
EDITED
$('#form_1 input').each(function(key, value) {
if ((this.type === "radio" || this.type === "checkbox") && this.checked === true) {
val = this.value;
} else {
val = this.value;
}
alert($('#'+this.id).attr('name') + ' = ' + val);
formData += '&'+$('#'+this.id).attr('name')+'='+val;
});
Ok, now I get every value for radio stations, etc., so I'm one step closer. You just need to get the values of the selected radio stations.
thank
source
share