iterate through passed URL params

Hi

I have the following code which works if I pass a querystring such as mypage.asp?a=hi&b=test&c=three&d=fist etc....

I want to be able to just pass a set of parameters to the page such as mypage.asp?hi,test,three,fist and let it just deal with however many are sent, how can I achieve this please

I then ned to pass these to the window operner function which for some reason needs everything with ' around otherwise I get obj1 is null errors

Regards
Neil

<html>

    <head>

    <title></title>

        <script language="javascript">

            function passBackArgs() {
            
                a = '<% =Request.QueryString("a") %>';
                b = '<% =Request.QueryString("b") %>';
                c = '<% =Request.QueryString("c") %>';
                d = '<% =Request.QueryString("d") %>';
                e = '<% =Request.QueryString("e") %>';
                f = '<% =Request.QueryString("f") %>';
             
                try {            
                    window.opener.jspassback(a,b,c,d,e,f);    
                    self.close();
                } catch(e) {
                    alert(e);
                    //alert("Parent Window is Closed!");
                }
            }
        </script>

    </head>

    <body onload="javascript: passBackArgs();"></body>

</html>

Open in new window

LVL 3
Neil ThompsonSenior Systems DeveloperAsked:
Who is Participating?
 
dimmergeekCommented:
dim str, arrSplit

str = Request.QueryString("values")
arrSplit = Split(str, ",")

i = 0
Do While i <= UBound(arrSplit)
     Add your code to execute for each value retuned here...
Loop

Open in new window

0
 
Barry62Commented:
You can't just pass values in a url.  The there has to be a name-value pair.  That's the only way it works.
0
 
dimmergeekCommented:
I have had success in passing values like this:

"page.asp?vals=a,b,c,d,e,f,g,h"

You can get your values string from the Request.QueryString and then dump your data into an array after slippting based on the comma.
Then, you just cound how many elements you have in your array and you should be set.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
Neil ThompsonSenior Systems DeveloperAuthor Commented:
Thanks dimmergeek that sounds like what im after but how would I achieve that?

I'm not too up with asp any more.
0
 
hieloCommented:
You can't just pass values in a url.  The there has to be a name-value pair.  That's the only way it works.
Actually, that is not true. You can get it from the Request.ServerVariables() Collection. Try:

Dim data
data=Split(Request.ServerVariables("QUERY_STRING"), ",")
For i=0 To UBound(data)
Response.Write data(i) & "<br >"
Next

Open in new window

0
 
Neil ThompsonSenior Systems DeveloperAuthor Commented:
just what I needed, many thanks
Neil
0
 
dimmergeekCommented:
You're welcome.  Thanks for the points!
0
 
Barry62Commented:
Thank you for the points!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.