1

After submitting a form, I get redirected to another form where I want to populate email field with the value from previous form. I have next url:

mysite.com/a/blog/?email=test%40email.com#form_20

How to make input with id="email" populated with test@email.com using javascript ?

UPDATE:

Thanks @MA-Maddin for helpful link: How to use JavaScript to fill a form on another page With this, I get email like: test%40email.com . I am wondering, how to combine

decodeURIComponent('%40') 

with provided solution:

window.location.search.replace(/^\?email=/, '')

Thanks.

Community
  • 1
  • 1
Dejan Munjiza
  • 790
  • 1
  • 12
  • 23
  • 2
    http://stackoverflow.com/questions/12183572/how-to-use-javascript-to-fill-a-form-on-another-page/12183659#12183659 – Martin Schneider Oct 13 '16 at 08:11
  • Thanks @MA-Maddin, do you know how to combine that with decodeURIComponent('%40'), so I can have normal email :) – Dejan Munjiza Oct 13 '16 at 08:24
  • `var GET = {}; var queryString = window.location.search.substr(1).split('&'); queryString.forEach(function(keyValuePair) { var splitPair = keyValuePair.split('='); var paramName = splitPair[0]; var paramVal = decodeURIComponent(splitPair[1]); GET[paramName] = paramVal; }); console.log(GET['email']);` – Martin Schneider Oct 13 '16 at 08:39
  • var uglymail = window.location.search.replace(/^\?email=/, ''); var mail = decodeURIComponent(uglymail); this is what I used. It is ok now. Thanks for help. – Dejan Munjiza Oct 13 '16 at 08:41

0 Answers0