hemtros
3/14/2017 - 7:39 PM

Get query string params in javascript directly from DOM

Get query string params in javascript directly from DOM

function GetAgentIds() {

 var agentIds = "";
 var rows = $("[id*='ctl00_cphMain_upAgents']")[0].children[2].children[0].children[0];
 
 
 for (var x = 1; x < rows.children.length; x++){
  var outerHTML = (rows.children[x].children[0].outerHTML).trim();        
     var vars = {};
     var parts = outerHTML.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
      vars[key] = value;
     });  
  console.log("Row: " + x + " " + vars["AgentId"]);
  agentIds += vars["AgentId"] + "$";
 }
 
 console.log("Agents Ids are: " + agentIds);
}