C Doug C Doug - 2 months ago 4x
HTML Question

How to initialize an element in an HTML page

I want to pass through the text data entered on the /index page (property address) and (email) to the /sign-up page.


The query string(s) are moving into the URL, however how do I populate the respective fields on the /sign-up page, with the text data provided in the URL?


(function(f, e, t){
initForm(f, e, t);
function initForm(oForm, element_name, init_txt) {
frmElement = oForm.elements[element_name];
frmElement.value = init_txt;
var queryStrng = [
full_name: "dave",
email: "email@to.do",
property_address: "prop address to do"
//queryStrng[0].full_name = document.getElementsByName("full_name").valueOf();
//var oFormObject = document.forms[0];



Try this function:

function GetURLParameter(sParam)
    var sPageURL = window.location.search.substring(1);
    var sURLVariables = sPageURL.split('&');
    for (var i = 0; i < sURLVariables.length; i++) 
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam) 
            return sParameterName[1];

 And this is how you can use this function assuming the URL is, 

var property_address = GetURLParameter('property_address');
var email = GetURLParameter('email');`