Link to home
Start Free TrialLog in
Avatar of Neil Thompson
Neil ThompsonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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

Avatar of Barry62
Barry62
Flag of United States of America image

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.
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.
Avatar of Neil Thompson

ASKER

Thanks dimmergeek that sounds like what im after but how would I achieve that?

I'm not too up with asp any more.
ASKER CERTIFIED SOLUTION
Avatar of dimmergeek
dimmergeek
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hielo
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

just what I needed, many thanks
Neil
You're welcome.  Thanks for the points!
Thank you for the points!