0

Here is my simple code . I'm trying to read values from URL and passing in textbox during page load. (CODE IS NOT WORKING) I'm learing JavaScript. Can anyone help me or suggest me better solution. Any Help will be appreciate. link can be

http://domian.com?UniqueID=123456&Email=n@gmail.com

<html>
 <head>
   <script type="text/javascript">
     function populate() 
     { 
       var varSection = window.location.search.substr(1);
       var varArray = varSection.split('&');

       for(var v=0; v<varArray.length; v++)
       { 
         var keyValueArray = varArray[v].split('=');
       }

       if(keyValueArray[0]=='UniqueID') 
       {
         varValue=keyValueArray[1]; 
         document.getElementById('email').value=varValue; 
         break;
       }  
     } 
 </script>
</head>
<body onload="populate()">

<h1>My Web Page</h1>
 <br>
 Email: 
 <input type="text" id="email" />
 <br>
 </body>
</html> 
morten.c
  • 3,346
  • 5
  • 38
  • 44
user3474130
  • 135
  • 1
  • 1
  • 7
  • Take a look at this question Its simillar to your question. http://stackoverflow.com/questions/4656843/jquery-get-querystring-from-url – Elias Soares Mar 28 '14 at 20:28
  • This is not an answer, but there is at least one typo in you're script part. Take a look at your `break` statement, it isn't even inside your `for { }` block. – morten.c Mar 28 '14 at 20:31

0 Answers0