Collecting Web Form Information Using a Loop

Phil Davis revdev at pdslabs.net
Wed Sep 1 13:06:09 EDT 2010


  On 9/1/10 9:34 AM, Gregory Lypny wrote:
> Hello everyone,
>
> On-rev question about collecting web form information.  Suppose I have a questionnaire that uses 40 sequentially named menus for the answer choices.  I could collect them individually like this.
>
> 	put $_POST["Q1"] into q1
> 	put $_POST["Q2"] into q2
> 	put $_POST["Q3"] into q3
> 	put $_POST["Q4"] into q4
> 	put $_POST["Q5"] into q5
> 	...
> 	put $_POST["Q40"] into q40
>
> But of course my first inclination is to avoid 40 lines and use a loop.  So I tried
>
> 	repeat with i=1 to 40
> 	put $_POST[(quote&  Q&  i&  quote)]&  comma after theSubmission
> 	end repeat
>
> and a number of variations, such as,
>
> 	(quote&  Q&  the value of i&  quote)
>
> but all I ever get returned is an empty list, i.e., {,,,,,,,,,,,,}.  Any suggestions?

Maybe break your one-liner into two:

repeat with i = 1 to 40
     put "Q" & i into tKey
     put $_POST[tKey] & comma after theSubmission
end repeat

I would be surprised if this didn't work.

Best -
Phil Davis

>
> Regards,
>
> Gregory
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>

-- 
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net




More information about the Use-livecode mailing list