Creating fields in a table based on a drop-down selection

Posted on 2006-05-23
Last Modified: 2010-04-25
Hi all,
I have a drop-down with the label " How many people...".and the values of 1,2,3,4 etc... I want the selected value of this drop-down to generate the correct amount of rows in a table. For example if the user selects 2 people, then two rows are added to a table so the user can enter personal information about them? Any suggestions as to the easiest way to do this?
Question by:dereksheahan
    1 Comment
    LVL 70

    Accepted Solution

    Hi derek,

    The concept is similar to creating a repeat region.  Put this code in where you want the table to start:


    echo "<table>";

    $i = 0; // start the counter here

    while ($i < $_POST['theformfieldwiththenumber']) {

    echo "<tr><td></td></tr>\n";



    if ($i == $_POST['theformfieldwiththenumber']) { echo"</table>\n"; }


    This while loop should produce the correct number of rows.  If the form is using GET, change the above from _POST to _GET.  Put whatever you like in the first echo statement or expand it into multiple statements.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Insert multiple row form with checkboxes 9 1,003
    website template 12 310
    slide show not working correctly 10 388
    page loads much slower in IE than chrome 9 1,050
    For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
    Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now