Reply to Re: Dynamic Form

Your name:

Reply:


Posted by Jerry Stuckle on 04/04/07 15:14

Jerim79 wrote:
> I need to create a form that takes a number that the user enters, and
> duplicates a question the number of times the user entered. For
> instance, if the customer enters 5 on the first page, when they press
> next the form generates "How old are you?" 5 times on the page. The
> customer will answer all 5 questions then press next. Finally, all the
> local variables get dynamically created and written to a database.
>
> I have already taken care of dynamically creating the question five
> times. Using a simple WHILE clause, this generates the correct number
> of questions. What I am having an issue with at this point, is how to
> dynamically create the local variables.For instance, for the question
> "How old are you?" I would need a unique variable for each instance;
> using something like $Age(n). So that for five times, it would
> automatically created variables $Age1 through $Age5. I have carried
> over the number to the submit page by creating the variable $Number
> and passing it along as hidden button on the form. $Age'$Number'
> seemed to work for creating the variable, but $_post["Age'$Number'"]
> doesn't work for referencing the global variable. I would need some
> way of looping through and dynamically creating the variables.
>
> I am willing to rethink my approach to the whole problem, so the door
> is wide open to suggestions.
>

A much easier way would be to just use an array:

<input name="age[]" ...>

Then your answers will be in the array $_POST['age'] or $_GET['age'],
depending on how you submit the form.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация