Get the query string value and display it in my html page

aWeseUnsus57

New Member
After redirecting to home.html page, i can see the querystring values which i had given in the previous page. \[code\]Home.html?FirstName=dd&LastName=ee&smtButton=Submit\[/code\]And am getting the result as:\[code\]firstname = undefinedlastname = undefinedage = undefined\[/code\]Could anyone help me to solve this?JS:\[code\]function getParams() { var idx = document.URL.indexOf('?'); var params = new Array(); if (idx != -1) { var pairs = document.URL.substring(idx + 1, document.URL.length).split('&'); for (var i = 0; i < pairs.length; i++) { nameVal = pairs.split('='); params[nameVal[0]] = nameVal[1]; } } return params;}params = getParams();firstname = unescape(params["firstname"]);lastname = unescape(params["lastname"]);age = unescape(params["age"]);document.write("firstname = " + firstname + "<br>");document.write("lastname = " + lastname + "<br>");document.write("age = " + age + "<br>");\[/code\]
 
Back
Top