adding additional field in a form with the click of a link

Discussion in 'PHP' started by babyphp, May 2, 2008.

  1. #1
    i have got a form which i have created already what i want now is something like once i have fill out the form and i have more than one types


    like entrying school detail if you attended more than one school click add to enter a new school with same kind of form

    here is my code

    <table class="tbl" border="0" cellspacing="1" cellpadding="5"width="50%">
    <tr>
    <td class="hr">Order Type</td>
    <td class="dr"><input type="text" name="LineOrderTypeID" value=""></td>
    </tr>
    <tr>
    <td class="hr">Telephone Number&nbsp;</td>
    <td class="dr"><input type="text" name="TelephoneNumber2" maxlength="45" value=""></td>
    </tr>
    <tr>
    <td class="hr">Existing Lines&nbsp;Number</td>
    <td class="dr"><input type="text" name="NumberExistingLines" value=""></td>
    </tr>
    <tr>
    <td class="hr">New Lines&nbsp;Number</td>
    <td class="dr"><input type="text" name="NumberNewLines" value=""></td>
    </tr>
    <tr>
    <td class="hr">From Line Type</td>
    <td class="dr"><?php
    $result = mysql_query("SELECT LineTypesID, Description FROM LineTypes");

    echo "<select name=\"LineTypesID\">";
    while ($row=mysql_fetch_array($result)) {
    $id = $row['LineTypesID'];
    $description = $row['Description'];
    echo "<option value=\"$id\">$description</option>";
    }
    echo "</select>";
    ?>
    </td>
    </tr>
    <tr>
    <td class="hr">To Line Type&nbsp;</td>
    <td class="dr"><?php
    $result = mysql_query("SELECT LineTypesID, Description FROM LineTypes");

    echo "<select name=\"LineTypesID\">";
    while ($row=mysql_fetch_array($result)) {
    $id = $row['LineTypesID'];
    $description = $row['Description'];
    echo "<option value=\"$id\">$description</option>";
    }
    echo "</select>";
    ?>
    </td>
    </tr>
    <tr>
    <td class="hr">Is Feature Line&nbsp;</td>
    <td class="dr"><select name="IsFeatureLine">
    <option value=""></option>
    <option value="Yes">Yes</option>
    <option value="No">No</option>
    </select></td>
    </tr>
    <tr>
    <td class="hr">Is Fax&nbsp;</td>
    <td class="dr"><select name="IsFax">
    <option value=""></option>
    <option value="Yes">Yes</option>
    <option value="No">No</option>
    </select></td>
    </tr>
    <tr>
    <td class="hr">Is PDQ&nbsp;</td>
    <td class="dr"><select name="IsPDQ">
    <option value=""></option>
    <option value="Yes">Yes</option>
    <option value="No">No</option>
    </select></td>
    </tr>
    <tr>
    <td class="hr">Is DSL&nbsp;</td>
    <td class="dr"><select name="IsDSL">
    <option value=""></option>
    <option value="Yes">Yes</option>
    <option value="No">No</option>
    </select></td>
    </tr>
    <tr>
    <td class="hr">Is Phone&nbsp;</td>
    <td class="dr"><select name="IsPhone">
    <option value=""></option>
    <option value="Yes">Yes</option>
    <option value="No">No</option>
    </select></td>
    </tr>
    <tr>
    <td class="hr">Line Extra</td>
    <td class="dr"><?php
    $result = mysql_query("SELECT LineExtraTypeID, Description FROM LineExtraTypes");

    echo "<select name=\"LineExtraTypeID\">";
    while ($row=mysql_fetch_array($result)) {
    $id = $row['LineExtraTypeID'];
    $description = $row['Description'];
    echo "<option value=\"$id\">$description</option>";
    }
    echo "</select>";
    ?>
    </td>
    </tr>
    </table>
     
    babyphp, May 2, 2008 IP
  2. lanmonkey

    lanmonkey Active Member

    Messages:
    549
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #2
    I dont understand the first couple of lines of your post.

    From what I can fathom of your request you would probably need to use javascript not php
     
    lanmonkey, May 2, 2008 IP
  3. CreativeClans

    CreativeClans Peon

    Messages:
    128
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can also do it with PHP, but it means the form will be sent each time the user clicks the "add" button, and you'll have to get the form data and put it in the form again, and create the form dynamically to be able to add a new field to it.
     
    CreativeClans, May 2, 2008 IP
  4. adrevol

    adrevol Active Member

    Messages:
    124
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #4
    if you dont want user to feel like submitting form each and every time, go for ajax, where in send the details to DB using ajax, at the same time display important order details at the bottom of the page,
     
    adrevol, May 2, 2008 IP
  5. omick16

    omick16 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    you could use sessions to temporarily store the school details.
     
    omick16, May 3, 2008 IP