Announcement

Collapse
No announcement yet.

Javascript & name/value pairs.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Javascript & name/value pairs.

    How do I use javascript to extract name/value pairs from urls?

    Thanks.
    Sig? What sig?

  • #2
    Code:
    //var uriString = 'http://www.deluxeportal.com/index.php?a=1&b=2&c=3';
    var uriString = window.location.href;
    var getVars = new Array();
    if (-1 != (quePos = uriString.indexOf('?')))
    {
     uriString = uriString.substr(quePos + 1);
     uriString = uriString.split(/&/);
     for (var i in uriString)
     {
      var currentVar = uriString[i];
      var equalPos = currentVar.indexOf('=');
      equalPos = equalPos==-1 ? currentVar.length : equalPos;
      var currentVal = currentVar.substr(equalPos + 1);
      currentVar = currentVar.substr(0, equalPos);
      getVars[currentVar] = unescape(currentVal);
     }
    }
    hope that helps

    Comment


    • #3
      Originally posted by Cyborg from DH
      Code:
      //var uriString = 'http://www.deluxeportal.com/index.php?a=1&b=2&c=3';
      var uriString = window.location.href;
      var getVars = new Array();
      if (-1 != (quePos = uriString.indexOf('?')))
      {
      uriString = uriString.substr(quePos + 1);
      uriString = uriString.split(/&/);
      for (var i in uriString)
      {
      var currentVar = uriString[i];
      var equalPos = currentVar.indexOf('=');
      equalPos = equalPos==-1 ? currentVar.length : equalPos;
      var currentVal = currentVar.substr(equalPos + 1);
      currentVar = currentVar.substr(0, equalPos);
      getVars[currentVar] = unescape(currentVal);
      }
      }
      hope that helps
      Thank you.

      I'm sure it will.

      I'll have a play around with that and see what I can do.
      Sig? What sig?

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...
      X