troubleshooting Question

Retrieve variables from Query String using

Avatar of TechMonster
TechMonster asked on
5 Comments1 Solution259 ViewsLast Modified:
I have a query string with first name and lastname.  
I was told to use the attached code to display the info..but it does not seem to be worklng.
my querystring variables looks like      ?fn=myFirstname&ln=myLastname

I would like to be able to pass these into the body...I have tried to do the Alert(lastname) but nothing comes up but "undefined"

<SCRIPT type ="text/javascript">
function qs() {
      var query =;
      var parms = query.split('&');
      for (var indx=0; indx<parms.length; indx++) {
            var pos = parms[indx].indexOf('=');
            if (pos > 0) {
                  var key = parms[indx].substring(0,pos);
                  var val = parms[indx].substring(pos+1);
                  qsParm[key] = val;
      return qsParm;
var firstname = qs['fn'];
var lastname = qs['ln'];





Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros