简体   繁体   中英

how to store input fields with sub input fields value in to database using JQuery with PHP?

I done something like bellow code and i want to store input fields value based on parent and child in MySQL database using JQuery PHP`. Basically i was done with single value but in my current task that look like tree with multiple Parent and it's Multiple child key Vlaue.

I am using this code:

$(function() {
    var scntDiv = $('#p_scents');
var i = $('#p_scents label').size() + 1;

$('#addScnt').live('click', function() {
$('<p>Keyword: '+i+'<a href="#" id="remScnt">Remove</a><br><label for="p_scnts"><input type="text" id="p_scnt" size="20" name="keyword[]" value="" placeholder="Enter Keyword" /><a href="#" id="addVar">Add Variants</a><a></a></label></p>').appendTo(scntDiv);
i++;
return false;
});

$('#remScnt').live('click', function() {
if( i >2 ) {
$(this).parents('p').remove();
i--;
}
return false;
});

$('#addVar').live('click', function() {
//alert();
$('<p><label for="var"><input type="text" id="p_scnt" size="20" name="p_scnt_' + i +'" value="" placeholder="Enter Vareyword" /></label> <a href="#" id="remVar">Remove Var</a></p>').appendTo($(this).next());
return false;
});


$('#remVar').live('click', function() {

$(this).parent('p').remove();


return false;
}); });
<h2><a href="#" id="addScnt">Add Another Input Box</a></h2><div id="p_scents">
<p>
Keyword: 1
<br>
<label for="p_scnts"><input type="text" id="p_scnt" size="20" name="keyword[]" value="" placeholder="Enter keyword">
<a href="#" id="addVar">Add Variants</a>
<a></a>
</label>
</p>
</div>

您必须将名为p_scnt_2的孩子设置为keyword1 [],然后找到父母和孩子

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM