[eluser]bohara[/eluser]
Thanks for replying. Let me see if I can clarify.
The html looks like this
Code:
<fieldset>
<legend><span>Customer Information</span></legend>
<ol>
<li><label>Company Name</label>
<? echo form_input('company_name'); ?></li>
<li><label>Notes</label>
<textarea name="notes" value="" rows="3" cols="50"></textarea></li>
</ol>
</fieldset>
<fieldset id="line_tems">
<legend><span>Traps</span></legend>
<ol>
<li>
<table cellspacing="0">
<thead>
<tr>
<th>Qty</th>
<th>Trap</th>
<th>Shatterproof ?</th>
</tr>
</thead>
<tbody id="container">
<tr id="row0">
<td>
<input type="text" name="quantity[0][0]" value="" maxlength="2" size="2" />
</td>
<td>
<? echo form_dropdown('bulb_type_id[0][1]', $bulb_types); ?>
</td>
<td>
<? echo form_checkbox('shatterproof[0][2]', 1, false); ?>
</td>
</tr>
</tbody>
</table>
</li>
</ol>
<p><a class="addRow" href="#">Add another trap</a></p>
</fieldset>
<fieldset>
<legend><span>Reminder Information</span></legend>
<ol>
<li><label>Email to</label>
<? echo form_input('email_to'); ?></field><br /></li>
<li><label>Remind me</label>
<? echo form_dropdown('reminder_date', $reminder_dates); ?></field> From <?=$created_at?></li>
</ol>
</fieldset>
When you click the 'addRow' link shown above another row is inserted to the form via AJAX that looks like this. with the form values incremented by 1 (below)
Code:
<tr id="row0">
<td>
<input type="text" name="quantity[1][0]" value="" maxlength="2" size="2" />
</td>
<td>
<? echo form_dropdown('bulb_type_id[1][1]', $bulb_types); ?>
</td>
<td>
<? echo form_checkbox('shatterproof[1][2]', 1, false); ?>
</td>
</tr>
The function that is inserting this data in my model is as follows:
Code:
function add_reminder()
{
$account_id = $this->session->userdata('account_id');
$this->account_id = $account_id;
$this->company_name = $_POST['company_name'];
$this->notes = $_POST['notes'];
$this->email_to = $_POST['email_to'];
$this->reminder_date = $_POST['reminder_date'];
$this->created_at = $_POST['created_at'];
$this->db->insert('reminders', $this);
// Insert line_items
$query = $this->db->query('SELECT id FROM reminders ORDER BY id DESC LIMIT 1');
$row = $query->row_array();
$reminder_id = $row['id'];
for ($i = 0; $i <= count($_POST['quantity'])-1; $i++) {
$sql = array(
$this->reminder_id = $reminder_id,
$this->quantity = $_POST['quantity'][$i][1],
$this->bulb_type_id = $_POST['bulb_type_id'][$i][2],
//$this->shatterproof = $_POST['shatterproof'][$i][3]
);
$this->db->insert('line_items', $sql);
}
}
In regards to the variable name, I agree it is lame

I am just trying to get it working at this point.
Everything up to the for loop executes as expected. I hope that clarifies things a bit. I don't think I am to far off as this was working at one point. Although I may have just been lucky.
Thanks again.