Form data can be used without submitting form.
We can use JS [jquery] for grabbing form data.
To send proper selected data to server side we first have to select desired data with jquery.
Then use ajax to send form data to server side without loading page.
1. Grab form data.
get all input
selector = $('input');
get all input with certain class
$('input[class=classname]');
get all checkbox input with checked option
$('input[type="checkbox"]:checked ');
$('input[type="checkbox"]:checked ').val(); // this will return only first value in array
get all radio input with checked option
$('input[type="radio"]:checked ');
$('input[type="radio"]:checked ').val(); // its ok to use for radio option.
get all user inputed data
we can use serialize function for this.
$(selector).serialize();
This will give selected input data to serialized formate like this T.
product_id=528&product_class_id=406&product_type_id=1
This even supports array data which we have to use for checkbox that has multiple optiondata.
We can use ajax to send data to server side.
In server side we can use serialize data and convert to array form.
parse_str($serializedata);
after this line we can grab above serializedata in array like:
$product_id = 528;
$product_class_id = 406;
$product_type_id = 1;
If it has array we can get as follows
$data = array(...);
we can also use
json_parse()
stingfy()