-3

I have a query string:

isUser=0&tokenId=911b7ce6-0ddb-4739-9a02-cd7304a2w&emId=19&url=dfsjgh&roll=s&commId=0

I would like to parse it and end up as follows:

var firstcharector=0;
var secondCharector=911b7ce6-0ddb-4739-9a02-cd7304a2w;
var thirdCharector=19;

How can I achieve this?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
ASUR
  • 405
  • 4
  • 10
  • 23
  • "want to", not "wanna". – T.J. Crowder Aug 26 '13 at 11:50
  • 1
    Use the search bar next time :) http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values – supertopi Aug 26 '13 at 11:51
  • 2
    "javascript" not "java scrpit" – fmgp Aug 26 '13 at 11:51
  • Try reading the javadoc for String. I'm sure there's something there that will help. – Eric Stein Aug 26 '13 at 11:59
  • Don't tag with Java nor JSP (nor C nor Python nor Flash etc) if you have a question about JavaScript. Further I also recommend to take some time apart to learn basic HTTP and web development concepts in order to get the terminology right. What you've there is called a query string. By the way, your `secondCharector` variable is in invalid syntax, but that's a different problem. – BalusC Aug 26 '13 at 18:56

1 Answers1

0

JAVA CODE

giving java code because of 'java','jsp' tag in the question

String partialURL; // the url in post is partial
String urlArray[] = String.split("&");

String tempArray[] = new String[2];
    
// expected
/*
urlArray[0] = "isUser=0"
urlArray[1] = "tokenId=911b7ce6-0ddb-4739-9a02-cd7304a2w"
urlArray[2] = "emId=19"
*/

for(int i=0;i<urlArray.length;i++)
{
   tempArray = urlArray[i].split("=");
   urlArray[i] = tempArray[1]; // after '=' sign
}

javascript : no idea

Community
  • 1
  • 1
Srinath Ganesh
  • 2,496
  • 2
  • 30
  • 60