Javascript Cloned Elements not passing to sql dbase

Friday, May 2, 2014

I'm appending the row of a table in my html for the user to have more options on a flight request. The problem is that I have been appending the rows correctly but when I submit the query it seems that only the first row is sent to the dbase. How do I save the other rows(2nd row and onwards) if there is any?


Here is my html code of the table



<table id="appendTable" border="1" cellpadding="10" class="table">
<tr>
<th>No</th>
<th>Date of Flight</th>
<th>Time</th>
<th>Airline</th>
<th>Origin</th>
<th>Destination</th>
</tr>
<tr>
<td>1</td>
<td>
<select id='month' class="box" name='fm[]' value="<?php echo date('m'); ?>" onChange='changemonth(this)'>
<?php
for ($i=1; $i<=12; $i++)
{
if($i<10)
{
$x = "0".$i;
}
else
{
$x = $i;
}
if($i==date('m'))
{
echo "<option value='".$x."' selected> $x </option>";
}
else
{
echo "<option value='".$x."'> $x </option>";
}
}
?>
</select>

<select class='box' id='day' value="<?php echo date('d');?>" name='fd[]'>
<?php
for ($i=1; $i<=31; $i++)
{
if($i<10)
{
$x = "0".$i;
}
else
{
$x = $i;
}
if($i==date('d'))
{
echo "<option value='".$x."' selected> $x </option>";
}
else
{
echo "<option value='".$x."'> $x </option>";
}
}
?>
</select>

<select class='box' id='year' value="<?php echo date('Y');?>" name='fy[]' onChange='changemonth()'>
<?php
for ($i=0; $i<5; $i++){
$x = (date('Y')) + $i;
echo "<option value='".$x."'> $x </option>";
}
?>
</select>
</td>

<td>
<select class="box" name="time[]">
<option value="AM">AM</option>
<option value="PM">PM</option>
</select>
</td>

<td>
<select class="box" name="airline[]">
<option value="Cebu Pacific">Cebu Pacific</option>
<option value="Philippine Airlines">Philippine Airlines</option>
</select>
</td>

<td>
<input class="box tags" id="stateSelect" type="text" name="origin[]">
</td>

<td>
<input class="box tags" id="stateSelect2" type="text" name="destination[]">
</td>
</tr>
</table>


The Javascript



function insRow()
{
var x=document.getElementById('appendTable');
var new_row = x.rows[1].cloneNode(true);
var len = x.rows.length;
new_row.cells[0].innerHTML = len;
var inp1 = new_row.cells[1].getElementsByTagName('select')[0]; //month
inp1.value=x.rows[a].cells[1].getElementsByTagName('select')[0].value;
inp1.id += len;
var inp2 = new_row.cells[1].getElementsByTagName('select')[1]; //day
inp2.value=x.rows[a].cells[1].getElementsByTagName('select')[1].value;
inp2.id += len;
var inp3 = new_row.cells[1].getElementsByTagName('select')[2]; //year
inp3.value=x.rows[a].cells[1].getElementsByTagName('select')[2].value;
inp3.id += len;
x.appendChild( new_row );
a++;
}


What codes am I missing here?







http://ift.tt/1nSmssc