Web Analytics Made Easy -
StatCounter automatically add row - CodingForum

Announcement

Collapse
No announcement yet.

automatically add row

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • automatically add row

    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...?


    PHP Code:
    <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

  • #2
    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.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

    Comment


    • #3
      Thanks raf, will post it in javascript section.

      cheers
      shaun

      Comment

      Working...
      X