I have a case I'd like to be solved. I've been learning CI Framework for almost a month now. and what I want to do is I want to store value from input fields in a form that I add dynamically into MySQL table but I have no idea how to do that. I already have the script in HTML + JavaScript for the view.
HTML script
<div class="input_fields_wrap">
<button class="add_field_button">Add More Fields</button>
<div>
<input type="text" name="mytext[]" placeholder="Account Title">
<input type="text" name="mytext2[]" placeholder="Description">
<input type="text" name="mytext3[]" placeholder="Credit">
<input type="text" name="mytext4[]" placeholder="Debit">
</div>
</div>
JavaScript script
<script type="text/javascript">
$(document).ready(function() {
var max_fields = 10; //maximum input boxes allowed
var wrapper = $(".input_fields_wrap"); //Fields wrapper
var add_button = $(".add_field_button"); //Add button ID
var x = 1; //initlal text box count
$(add_button).click(function(e){ //on add input button click
e.preventDefault();
if(x < max_fields){ //max input box allowed
x++; //text box increment
$(wrapper).append('<div><input type="text" name="mytext[]" placeholder="Account Title"><input type="text" name="mytext2[]" placeholder="Description"><input type="text" name="mytext3[]" placeholder="Credit"><input type="text" name="mytext4[]" placeholder="Debit"><a href="#" class="remove_field">Remove</a></div>'); //add input box
}
});
$(wrapper).on("click",".remove_field", function(e){ //user click on remove text
e.preventDefault(); $(this).parent('div').remove(); x--;
})
});
</script>
is there anyone can help me to pass the value into database from controller? sorry I'm new to CI Framework so please forgive me by asking this kind of question.