Arrays to become variables

Results 1 to 2 of 2

Thread: Arrays to become variables

  1. #1
    Join Date
    Dec 1969

    Default Arrays to become variables

    Okay, I got validation to work. Now to display the list of products dynamically.<BR><BR>In the logincheck.asp code it gets the products the client owns and stores it in the querystring as a comma delim number. On the next page it takes it, splits it, and stores it as an array. Now I want to be able to write this for each product...<BR><BR>If productsArray = "1" then<BR>Session("writer") = now<BR>response.write "&#060;a href=""writer.asp""&#062;Jargon Writer&#060;/a&#062;"<BR><BR>If productsArray = "2" then<BR>Session("reader") = now<BR>response.write "&#060;a href=""reader.asp""&#062;Jargon Reader&#060;/a&#062;"<BR><BR>But I tried this and it gives me a type mismatch error. How do I fix that. Or how can I store each comma number as its own var so I DON&#039T have to do a loop.<BR><BR>Thanks,<BR>Jeremy

  2. #2
    Join Date
    Dec 1969

    Default RE: Arrays to become variables

    You *really* need to go get a beginning ASP book and learn the fundamentals of VBScript (or JScript) programming.<BR><BR>To access an *ELEMENT* of an array in VBScript, you simply do<BR><BR>If productsArray( elementNumber ) = "...whatever..." Then<BR><BR>where the elementNumber can be *either* a variable or simply a number.<BR><BR>But why don&#039t you want to do a loop? Most of the time, a loop is the *right* thing to do. I&#039d bet money that it is in this case, as well!<BR><BR>Oh...and do consider using VBScript&#039s SELECT CASE statement. Not sure it applies to your code, but I&#039d suspect it does.<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