Dynamic Arrays??

Results 1 to 2 of 2

Thread: Dynamic Arrays??

  1. #1
    Join Date
    Dec 1969

    Default Dynamic Arrays??

    Rephrasing a question from yesterday...<BR><BR>With the following code, I&#039;m trying to:<BR><BR>1)Pass a session collection to a local array for modification.<BR>2)Capture values from a submitted form and add them to the array, while preserving existing array elements.<BR>3)Redimension the array dynamically using Request.Form.Count, since all fields in the form are optional course choices selectable with checkboxes or radio buttons.<BR>4)Loop through the submitted form values and add them to the array, beginning at the Ubound of the existing array element (the &#039;If left(item,2) &#060;&#062; "fo" then&#039; statement is to exclude the &#039;formSubmitted&#039; hidden field that triggers the script).<BR>5)Pass the local array back to the session object for use on other pages (meant to function as a sort of &#039;shopping cart&#039; for class registration).<BR><BR>&#060;% <BR> If Request.Form("formSubmitted")= "yes" then <BR> &#039; Declare variables and capture form values <BR> Dim schedule <BR> Dim i <BR> Dim lngUbound <BR> schedule = Session("schedule") <BR> i = Ubound(schedule) + 1 <BR> lngUbound = Ubound(schedule)+ Request.Form.Count <BR> &#039; redimension array and populate with form values <BR> ReDim Preserve schedule(lngUbound) <BR> For each item in Request.Form <BR> If left(item,2) &#060;&#062; "fo" then <BR> schedule(i) = item <BR> i = i + 1 <BR> End if <BR> Next <BR> &#039; pass array elements to session variable and redirect <BR> Session("schedule") = schedule <BR> Response.Redirect("/admissions/prelim-registration/schedule-02.asp") <BR> End if <BR>%&#062;<BR><BR>My questions are:<BR><BR>1)Why is the code capturing form element names rather than values? I thought "item" indicated value.<BR>2)Is this approach viable, or would I be better off passing values to a DB? That still leaves the problem of capturing an undetermined number of form value submission for DB Insert.<BR>3)Would this be made easier by putting each choice into it&#039;s own form, so each course is selected one at a time, rather than trying to write scripts to capture with unknown quantities?<BR><BR>Many thanks!

  2. #2
    Join Date
    Dec 1969

    Default RE: Dynamic Arrays??

    1) No, item gives you the name. You have to do Request.Form(item) to get the value.<BR><BR>2) This seems fine.<BR><BR>3) Who knows.

Posting Permissions

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