Created
January 12, 2020 21:06
-
-
Save jasdeepkhalsa/be478005fa82513c1e4ab30f59dfc37b to your computer and use it in GitHub Desktop.
Read URL Query Strings for Data Prepopulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Data pre-population | |
var queryStrings = decodeURIComponent(location.search).split(/[?&]/).reduce(function(total, qs) { | |
total[qs.split('=')[0]] = qs.split('=')[1]; | |
return total; | |
}, {}); | |
if (queryStrings) { | |
var inviteeEmailValue = queryStrings['Email']; | |
var inviteeFullNameValue = queryStrings['Name']; | |
var inviteeMobileValue = queryStrings['mobile']; | |
var inviteeEmailElem = document.getElementById('email'); | |
var inviteeFullNameElem = document.getElementById('full_name'); | |
var inviteeMobileElem = document.getElementById('mobile'); | |
if (inviteeEmailValue) { | |
inviteeEmailElem.value = inviteeEmailValue; | |
inviteeEmailElem.disabled = true; | |
} | |
if (inviteeFullNameValue) { | |
inviteeFullNameElem.value = inviteeFullNameValue; | |
inviteeFullNameElem.disabled = true; | |
} | |
if (inviteeMobileValue) { | |
inviteeMobileElem.value = inviteeMobileValue; | |
inviteeMobileElem.disabled = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment