?
Solved

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

Posted on 2006-05-23
2
Medium Priority
?
120 Views
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?
Thanks,
D
0
Comment
Question by:dereksheahan
1 Comment
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 1800 total points
ID: 16747737
Hi derek,

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

<?php

echo "<table>";

$i = 0; // start the counter here

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

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

}

$i++;

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

850 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