Please help with looping through array of variable

Results 1 to 3 of 3

Thread: Please help with looping through array of variable

  1. #1
    Join Date
    Dec 1969
    Posts
    54

    Default Please help with looping through array of variable

    I have a form that posts to another page a set of form variables and I want to be able to loop through them. Any help is greatly appreciated, thanks!<BR><BR>The format is always "prompt0=somevalue" and the next would be prompt1=somevalue, etc.<BR><BR>So I would like to be able to loop through these somehow to be able to put them into variables of their own.<BR><BR>Thanks!

  2. #2
    Join Date
    Dec 1969
    Posts
    583

    Default RE: Please help with looping through array of vari

    Option Explicit<BR><BR>Dim FormItem<BR><BR>For Each FormItem In Request.Form<BR>Response.Write FormItem & " " & Request.Form(FormItem) & "&lt;br&gt;"<BR>Next<BR><BR><BR>Something like that?

  3. #3
    Join Date
    Dec 1969
    Posts
    96,118

    Default cfs idea works...

    ...but if you need more control, you could just use:<BR><BR>&#060;%<BR>&#039; change 21 as appropriate<BR>Dim prompts(21)<BR><BR>For count = 0 To 21<BR> prompts(count) = Request("prompt" & count)<BR>Next<BR>%&#062;<BR><BR>Or something like that. You most *certainly* do NOT want individual variables like<BR> prompt0<BR> prompt1<BR> etc.<BR><BR>Really ugly.<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •