Dynamic Form Creation

I searched for a while and could not find anything of relevance to what I am looking for, so forgive me if I accidentally overlooked the obvious.

I want to be able to create a dynamic form that gives a slect field that creates multiple input fields.

I have this (just psudo typed):

echo "

How many names do you want to enter? ";

$name = $_post[‘name’];

for($i = 1; $i <= $name; $i++) { 
     $bob = 'name' . $i;

echo "
name $i


My first problem I run into is
Notice: Undefined index: name

The second problem is, how can I refresh the number of options without having to go to a new webpage? Is that possible? I have a work around on another page, but it uses two separate pages, I want just one.

Is this called something that I can do a search for?

Thanks in advance!

As for being able to create the form dynamically without going to another page… The answer is yes and no…

You must resubmit the form in order to get new information. PHP is a server-side script. Any processing has to be done on the server.

However, you don’t have to have a new page… you can resubmit the form to itself.


<? if(isset($send)) { //DISPLAY SECOND SET OF DATE (PAGE2) } Else { //DISPLAY FIRST SET OF DATA (PAGE 1) } ?>

There is however a second option called AJAX. Its becoming more popular. I have not used it, but hear it can be pretty powerful.

As for the Error, it is just a notice. You should define the variable name before you use it. You can however turn notices off by placing the function error_reporting(“SOMELEVEL”) at the top of your pages… Here is a link to find out which level of Error Reporting you would like. http://us2.php.net/manual/en/function.e … orting.php

If you wanted to get rid of this without Error Reporting Function I believe you can just place var variablename = “”;

Hope that helps!

Sponsor our Newsletter | Privacy Policy | Terms of Service