Get Form all field value at a time by JQUERY.
You can get form all data at a time by clicking any field.Only jquery serializeArray function can do this. Here is very important thing is all field class name must be same, Below example all field class name is “Target”,
JQUERY CODE:
jQuery(document).ready(function () {
jQuery(‘.target’).change(function() {
var formAllData;
var fieldName;
var fieldValue;
var grossTotal=0;
formAllData = $(‘#getAllData’).serializeArray();
var dataArray = new Object();
for( index in formAllData)
{
if(formAllData[index].value) {
//dataArray[perfTimes[index].name] = perfTimes[index].value;
fieldName =formAllData[index].name;
fieldValue = formAllData[index].value;
grossTotal += parseInt(fieldValue);
//alert(fieldName);
//alert(fieldValue);
}
}
var pre_gross_price = jQuery(“#priceGross”).val(grossTotal);
});
});
HTML CODE :
<form name=”getAllData” id=”getAllData” action=”#”>
<input type=”text” name=”priceGross” id=”priceGross” value=”1000″ />
<input type=”checkbox” name=”Attribute1″ id=”Attribute1″ value=”600″ />
<input type=”checkbox” name=”Attribute2″ id=”Attribute1″ value=”600″ />
<input type=”checkbox” name=”Attribute3″ id=”Attribute1″ value=”600″ />
<input type=”radio” name=”Size” id=”Size” value=”300″ /> XL
<input type=”radio” name=”Size” id=”Size” value=”500″ /> XXL
<select name=”color” id=”color”>
<option value=”100″>Red</option>
<option value=”200″>Blue</option>
<option value=”300″>Green</option>
</select>
</form>