| 
	
 | 
 Posted by Jerim79 on 04/04/07 12:27 
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.
 
  
Navigation:
[Reply to this message] 
 |