Im currently using ajax to save values from my form and its working well. The problem is when I have parent child forms its no longer working. Here is my ajax code:
function saveChildren_ajax(){
$.ajax({
type: "POST",
url: "addchildren.php",
data: jQuery("#myform > .childrenSave").serialize(),
cache: false,
success: function(data){
//do anything
}
});
}
And my html code:
<form id="myform" >
<form class="childrenSave">
<input type="text" class="form-control" name="i_child" id="i_child">
Gender:
<input type="radio" name="i_optgender" value="Male" checked>Male
<input type="radio" name="i_optgender" value="Female">Female
<input type="number" class="form-control" name="i_age" id="i_age">
<button type="button" onclick="saveChildren_ajax()"> Add another child </button>
</form>
</form>
Please help me how to get the value from a parent child Forms Thanks!