PDA

View Full Version : automatically add row


vandaddy
09-26-2006, 04:09 AM
i have a section of a form where you enter vehicle expenses for a taxi shift, the way it is set up at the moment is so that there are 20 values in a vehicle expenses array so that you can enter up to 20 different expenses. Is there a way that i can have it so that it only shows one of the 20 arrays and when value1 is filled in it adds a new row below to enter value2 etc...?


<tr bordercolor="#000000">
<td height="26"><div align="center"><strong><font color="#000000">
<select name="P_ExpenseID1" tabindex="24" onBlur="mark_delete()">
<option></option>
<?php
while ($exprow = mysql_fetch_object ($squery_result))
{ ?>
<option value="<?php print $exprow->ExpenseId ; ?>"><?php print $exprow->ExpenseType; ?></option>
<?php
}
?>
</select>
</font></strong> <strong>
</strong></div></td>
<td width="29%"><div align="center"><strong>
<input type="text" name="ExpQty1" tabindex="25">
</strong></div></td>

<td width="30%">
<div align="center"><strong>
<input type="text" name="ExpValue1" onBlur="totalexp()" onchange="expenseID1()" tabindex="26" value="<?php print $_POST['ExpValue1'];?>">
</strong></div></td>
</tr>

each row contains the expense type, expense quantity and expense value. I want it to add a new row when the expense value is greater than 0.

thanks
shaun

raf
09-26-2006, 08:51 AM
welcome here !

what you describe is a clientside action, so i'd look for a clientside sollution --> add the row with javascript.
for a php sollution, you'd need to post the form after completing the first row (for instance by showing a 'add expense' button) and then reload the page with an addition row. You'd then need a second submibutton to post all expenses and move on to the next page.

vandaddy
09-27-2006, 02:12 AM
Thanks raf, will post it in javascript section.

cheers
shaun