I'm using CodeIgniter and I'm having trouble retrieving an array from the input. I have been searching but I can't solve this. The thing is i'm using a button to dynamically add text boxes.
(HTML from view.php)
<?php echo form_open('verifynovareceita'); ?>
(...)
<div id="ings">
<p>Ingredients:</p>
<input type="text" name="ings[]"/>
</div>
<input type="button" value="Add another ingrdient" name="add" onClick="addTextBox()">
(...)
<script type='text/javascript'>
function addTextBox() {
var ings = document.getElementById("ings");
var input1 = document.createElement("input");
input1.type = "text";
input1.name = "ings[]";
ings.appendChild(input1);
}
And the (visual) result is what it's expected. It creates as many inputs as I wanted. The problem is when it comes to retrieving the data from the POST array:
(PHP from controller)
$ings = $this->input->post('ings');
$row_count = count($ings);
$row_count has value 1, no matter how many text boxes existed. Is there a problem with my code? Or is it the fact that i'm using form_open that makes it impossible to work? I've tried to do the same thing, without codeigniter and it worked fine... I appreciate any help! Thank you in advance.