Javascript Form Variables











up vote
-2
down vote

favorite












I have a form that a user would fill, I would like to submit those answers to variables in javascript and then call a function to display all the data entered into the form on a different page. For example the form is on 1.html, the user presses the submit button, is redirected to 2.html and the submitted information is shown here. Here is my form:



<form action="addaddresspage3.html" method="post" id="form" class="form">
<div id="form1">

<div class="row form-row form-bg">
<div class="container">
<div class="col-md-12 form-wrapper">
<form role="form">
<div class="form-content">
<legend class="hd-default">Billing Address</legend>


<div class="row">
<div class="form-group col-md-4 col-sm-6">
<label for="first-name">First Name(s)*:</label>
<input type="text" id="firstname" class="form-control" placeholder="First Name(s)" required="">
</div>
</div>

<div class="row">
<div class="form-group col-md-4 col-sm-6">
<label for="password">Surname*:</label>
<input type="text" id="surname" class="form-control" placeholder="Surname" required="">
</div>
</div>

<div class="col-md-12">
<div class="row">
<div class="form-group col-md-3 col-sm-3">
<label>Country of Home Address</label>
<select name="title" id="addresslist" class="form-control">
<option value="1">Select Address</option>
<option value="1">United Kingdom</option>
<option value="2">Saudi Arabia</option>
<option value="3">Iran</option>
<option value="4">Nigeria</option>
</select>

</div>
</div>
<div class="row">
<div class="form-group col-md-4 col-sm-6">


<label for="street_<cfoutput>#Add#</cfoutput>">House number and street:</label>
<input type="text" name="street_#Add#" validateat="onSubmit" validate="maxlength" required="yes" id="autocomplete" size="54" maxlength="120" message="Please enter owner #Peoplecount#'s mailing address." onFocus="geolocate()" placeholder="Please enter your house number and street">


<p>

<label for="city_<cfoutput>#Add#</cfoutput>">Town:</label>
<input type="text" name="city_#Add#" validateat="onSubmit" validate="maxlength" required="yes" id="locality" size="30" maxlength="50" message="Please enter owner #Peoplecount#'s mailing city." value="">

</p>

<label for="street_<cfoutput>#Add#</cfoutput>">Postcode:</label>
<input type="text" name="postal_#Add#" required="yes" id="postal_code" size="8" maxlength="12" message="Please enter owner #Peoplecount#'s mailing zip code." value="">
</div>
</div>
</div>
</div>

</div>
<input type="submit" id="continue" disabled="disabled" value="Add Address"/>
</div>









share|improve this question




















  • 1




    Where is the JavaScript that you've written? Note that variables won't carry a value to the next page, but you can store the values in perhaps local storage, or maybe include them in the query string for the next page.
    – David
    Apr 8 '16 at 18:38










  • So is there no way to pass variables from page to page?
    – Alice
    Apr 8 '16 at 18:41










  • You can store or submit values just as I described. But a "variable", as an in-memory concept, won't be available outside the scope of that variable's lifespan. This is true in every programming language.
    – David
    Apr 8 '16 at 18:43










  • This is only needed for a prototype so a short lifespan is fine @David
    – Alice
    Apr 8 '16 at 18:49












  • I have no idea what you meant by that reply. And I'm pretty sure neither did you.
    – David
    Apr 8 '16 at 18:50















up vote
-2
down vote

favorite












I have a form that a user would fill, I would like to submit those answers to variables in javascript and then call a function to display all the data entered into the form on a different page. For example the form is on 1.html, the user presses the submit button, is redirected to 2.html and the submitted information is shown here. Here is my form:



<form action="addaddresspage3.html" method="post" id="form" class="form">
<div id="form1">

<div class="row form-row form-bg">
<div class="container">
<div class="col-md-12 form-wrapper">
<form role="form">
<div class="form-content">
<legend class="hd-default">Billing Address</legend>


<div class="row">
<div class="form-group col-md-4 col-sm-6">
<label for="first-name">First Name(s)*:</label>
<input type="text" id="firstname" class="form-control" placeholder="First Name(s)" required="">
</div>
</div>

<div class="row">
<div class="form-group col-md-4 col-sm-6">
<label for="password">Surname*:</label>
<input type="text" id="surname" class="form-control" placeholder="Surname" required="">
</div>
</div>

<div class="col-md-12">
<div class="row">
<div class="form-group col-md-3 col-sm-3">
<label>Country of Home Address</label>
<select name="title" id="addresslist" class="form-control">
<option value="1">Select Address</option>
<option value="1">United Kingdom</option>
<option value="2">Saudi Arabia</option>
<option value="3">Iran</option>
<option value="4">Nigeria</option>
</select>

</div>
</div>
<div class="row">
<div class="form-group col-md-4 col-sm-6">


<label for="street_<cfoutput>#Add#</cfoutput>">House number and street:</label>
<input type="text" name="street_#Add#" validateat="onSubmit" validate="maxlength" required="yes" id="autocomplete" size="54" maxlength="120" message="Please enter owner #Peoplecount#'s mailing address." onFocus="geolocate()" placeholder="Please enter your house number and street">


<p>

<label for="city_<cfoutput>#Add#</cfoutput>">Town:</label>
<input type="text" name="city_#Add#" validateat="onSubmit" validate="maxlength" required="yes" id="locality" size="30" maxlength="50" message="Please enter owner #Peoplecount#'s mailing city." value="">

</p>

<label for="street_<cfoutput>#Add#</cfoutput>">Postcode:</label>
<input type="text" name="postal_#Add#" required="yes" id="postal_code" size="8" maxlength="12" message="Please enter owner #Peoplecount#'s mailing zip code." value="">
</div>
</div>
</div>
</div>

</div>
<input type="submit" id="continue" disabled="disabled" value="Add Address"/>
</div>









share|improve this question




















  • 1




    Where is the JavaScript that you've written? Note that variables won't carry a value to the next page, but you can store the values in perhaps local storage, or maybe include them in the query string for the next page.
    – David
    Apr 8 '16 at 18:38










  • So is there no way to pass variables from page to page?
    – Alice
    Apr 8 '16 at 18:41










  • You can store or submit values just as I described. But a "variable", as an in-memory concept, won't be available outside the scope of that variable's lifespan. This is true in every programming language.
    – David
    Apr 8 '16 at 18:43










  • This is only needed for a prototype so a short lifespan is fine @David
    – Alice
    Apr 8 '16 at 18:49












  • I have no idea what you meant by that reply. And I'm pretty sure neither did you.
    – David
    Apr 8 '16 at 18:50













up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











I have a form that a user would fill, I would like to submit those answers to variables in javascript and then call a function to display all the data entered into the form on a different page. For example the form is on 1.html, the user presses the submit button, is redirected to 2.html and the submitted information is shown here. Here is my form:



<form action="addaddresspage3.html" method="post" id="form" class="form">
<div id="form1">

<div class="row form-row form-bg">
<div class="container">
<div class="col-md-12 form-wrapper">
<form role="form">
<div class="form-content">
<legend class="hd-default">Billing Address</legend>


<div class="row">
<div class="form-group col-md-4 col-sm-6">
<label for="first-name">First Name(s)*:</label>
<input type="text" id="firstname" class="form-control" placeholder="First Name(s)" required="">
</div>
</div>

<div class="row">
<div class="form-group col-md-4 col-sm-6">
<label for="password">Surname*:</label>
<input type="text" id="surname" class="form-control" placeholder="Surname" required="">
</div>
</div>

<div class="col-md-12">
<div class="row">
<div class="form-group col-md-3 col-sm-3">
<label>Country of Home Address</label>
<select name="title" id="addresslist" class="form-control">
<option value="1">Select Address</option>
<option value="1">United Kingdom</option>
<option value="2">Saudi Arabia</option>
<option value="3">Iran</option>
<option value="4">Nigeria</option>
</select>

</div>
</div>
<div class="row">
<div class="form-group col-md-4 col-sm-6">


<label for="street_<cfoutput>#Add#</cfoutput>">House number and street:</label>
<input type="text" name="street_#Add#" validateat="onSubmit" validate="maxlength" required="yes" id="autocomplete" size="54" maxlength="120" message="Please enter owner #Peoplecount#'s mailing address." onFocus="geolocate()" placeholder="Please enter your house number and street">


<p>

<label for="city_<cfoutput>#Add#</cfoutput>">Town:</label>
<input type="text" name="city_#Add#" validateat="onSubmit" validate="maxlength" required="yes" id="locality" size="30" maxlength="50" message="Please enter owner #Peoplecount#'s mailing city." value="">

</p>

<label for="street_<cfoutput>#Add#</cfoutput>">Postcode:</label>
<input type="text" name="postal_#Add#" required="yes" id="postal_code" size="8" maxlength="12" message="Please enter owner #Peoplecount#'s mailing zip code." value="">
</div>
</div>
</div>
</div>

</div>
<input type="submit" id="continue" disabled="disabled" value="Add Address"/>
</div>









share|improve this question















I have a form that a user would fill, I would like to submit those answers to variables in javascript and then call a function to display all the data entered into the form on a different page. For example the form is on 1.html, the user presses the submit button, is redirected to 2.html and the submitted information is shown here. Here is my form:



<form action="addaddresspage3.html" method="post" id="form" class="form">
<div id="form1">

<div class="row form-row form-bg">
<div class="container">
<div class="col-md-12 form-wrapper">
<form role="form">
<div class="form-content">
<legend class="hd-default">Billing Address</legend>


<div class="row">
<div class="form-group col-md-4 col-sm-6">
<label for="first-name">First Name(s)*:</label>
<input type="text" id="firstname" class="form-control" placeholder="First Name(s)" required="">
</div>
</div>

<div class="row">
<div class="form-group col-md-4 col-sm-6">
<label for="password">Surname*:</label>
<input type="text" id="surname" class="form-control" placeholder="Surname" required="">
</div>
</div>

<div class="col-md-12">
<div class="row">
<div class="form-group col-md-3 col-sm-3">
<label>Country of Home Address</label>
<select name="title" id="addresslist" class="form-control">
<option value="1">Select Address</option>
<option value="1">United Kingdom</option>
<option value="2">Saudi Arabia</option>
<option value="3">Iran</option>
<option value="4">Nigeria</option>
</select>

</div>
</div>
<div class="row">
<div class="form-group col-md-4 col-sm-6">


<label for="street_<cfoutput>#Add#</cfoutput>">House number and street:</label>
<input type="text" name="street_#Add#" validateat="onSubmit" validate="maxlength" required="yes" id="autocomplete" size="54" maxlength="120" message="Please enter owner #Peoplecount#'s mailing address." onFocus="geolocate()" placeholder="Please enter your house number and street">


<p>

<label for="city_<cfoutput>#Add#</cfoutput>">Town:</label>
<input type="text" name="city_#Add#" validateat="onSubmit" validate="maxlength" required="yes" id="locality" size="30" maxlength="50" message="Please enter owner #Peoplecount#'s mailing city." value="">

</p>

<label for="street_<cfoutput>#Add#</cfoutput>">Postcode:</label>
<input type="text" name="postal_#Add#" required="yes" id="postal_code" size="8" maxlength="12" message="Please enter owner #Peoplecount#'s mailing zip code." value="">
</div>
</div>
</div>
</div>

</div>
<input type="submit" id="continue" disabled="disabled" value="Add Address"/>
</div>






javascript jquery html forms






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









Flimzy

35.6k96395




35.6k96395










asked Apr 8 '16 at 18:34









Alice

13




13








  • 1




    Where is the JavaScript that you've written? Note that variables won't carry a value to the next page, but you can store the values in perhaps local storage, or maybe include them in the query string for the next page.
    – David
    Apr 8 '16 at 18:38










  • So is there no way to pass variables from page to page?
    – Alice
    Apr 8 '16 at 18:41










  • You can store or submit values just as I described. But a "variable", as an in-memory concept, won't be available outside the scope of that variable's lifespan. This is true in every programming language.
    – David
    Apr 8 '16 at 18:43










  • This is only needed for a prototype so a short lifespan is fine @David
    – Alice
    Apr 8 '16 at 18:49












  • I have no idea what you meant by that reply. And I'm pretty sure neither did you.
    – David
    Apr 8 '16 at 18:50














  • 1




    Where is the JavaScript that you've written? Note that variables won't carry a value to the next page, but you can store the values in perhaps local storage, or maybe include them in the query string for the next page.
    – David
    Apr 8 '16 at 18:38










  • So is there no way to pass variables from page to page?
    – Alice
    Apr 8 '16 at 18:41










  • You can store or submit values just as I described. But a "variable", as an in-memory concept, won't be available outside the scope of that variable's lifespan. This is true in every programming language.
    – David
    Apr 8 '16 at 18:43










  • This is only needed for a prototype so a short lifespan is fine @David
    – Alice
    Apr 8 '16 at 18:49












  • I have no idea what you meant by that reply. And I'm pretty sure neither did you.
    – David
    Apr 8 '16 at 18:50








1




1




Where is the JavaScript that you've written? Note that variables won't carry a value to the next page, but you can store the values in perhaps local storage, or maybe include them in the query string for the next page.
– David
Apr 8 '16 at 18:38




Where is the JavaScript that you've written? Note that variables won't carry a value to the next page, but you can store the values in perhaps local storage, or maybe include them in the query string for the next page.
– David
Apr 8 '16 at 18:38












So is there no way to pass variables from page to page?
– Alice
Apr 8 '16 at 18:41




So is there no way to pass variables from page to page?
– Alice
Apr 8 '16 at 18:41












You can store or submit values just as I described. But a "variable", as an in-memory concept, won't be available outside the scope of that variable's lifespan. This is true in every programming language.
– David
Apr 8 '16 at 18:43




You can store or submit values just as I described. But a "variable", as an in-memory concept, won't be available outside the scope of that variable's lifespan. This is true in every programming language.
– David
Apr 8 '16 at 18:43












This is only needed for a prototype so a short lifespan is fine @David
– Alice
Apr 8 '16 at 18:49






This is only needed for a prototype so a short lifespan is fine @David
– Alice
Apr 8 '16 at 18:49














I have no idea what you meant by that reply. And I'm pretty sure neither did you.
– David
Apr 8 '16 at 18:50




I have no idea what you meant by that reply. And I'm pretty sure neither did you.
– David
Apr 8 '16 at 18:50












3 Answers
3






active

oldest

votes

















up vote
1
down vote













As long as the two are on the same domain you can set the data to cookies and repopulate them on the next page..



Page1



function setCookie(name, value) {
var cookie = name + "=" + escape(value) + ";";
document.cookie = cookie;
}

$("#form1").submit(function(){
setCookie("input1", $("#input1").val()); // do this for all inputs
});


Page2



function getCookie(name) {
var chunks = document.cookie.split(";");
for(var i=chunks.length; i--;){
if(chunks[i].trim().split("=")[0].trim() == name){
return chunks[i].trim().split("=")[1].trim();
}
}
return null;
}

$(document).ready(function(){
$("#input1").val(getCookie("iunput1")); // do the same for the other inputs
});





share|improve this answer





















  • Thank you for your help. I have copied the whole of the page 2, after editing the fields. But the page is just blank, do I need to display the values such as an alert?
    – Alice
    Apr 8 '16 at 18:48










  • you have to add your own element id's.. i just made up $("#input1")..
    – Occam's Razor
    Apr 8 '16 at 18:52










  • Yeah I have, thats what I meant when I said 'editing the fields'. The element id's are correct, just nothing is shown. I dont think the elements are being disppalyed
    – Alice
    Apr 8 '16 at 19:00










  • if you have firefox you can check the cookies in the cookies tab in the console, i'm sure it's there for chome too but idk..
    – Occam's Razor
    Apr 8 '16 at 19:04










  • php is the easiest way to go.. are you working on a server?
    – Occam's Razor
    Apr 8 '16 at 19:05


















up vote
0
down vote













Either use a service to store your value or web storage like localStorage pr sessionStorage to save you values from the form on page1.html and fetch them on form2.html to use






share|improve this answer





















  • Could this not be done by either simple HTML or JS?
    – Alice
    Apr 8 '16 at 18:41










  • Yes. If you provide the piece of JS code your sample html files, we may use web storage to do that
    – Aditya Singh
    Apr 8 '16 at 18:43










  • I don't have any JS, just that form
    – Alice
    Apr 8 '16 at 18:49


















up vote
0
down vote













You can persist values using local storage. For example, to write a value to storage:



localStorage.setItem('myValue', someVariable);


Then, on the next page, fetch that value:



var someVariable = localStorage.getItem('myValue');


And when you're done with the value in storage, be sure to remove it:



localStorage.removeItem('myValue');





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36506851%2fjavascript-form-variables%23new-answer', 'question_page');
    }
    );

    Post as a guest
































    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    As long as the two are on the same domain you can set the data to cookies and repopulate them on the next page..



    Page1



    function setCookie(name, value) {
    var cookie = name + "=" + escape(value) + ";";
    document.cookie = cookie;
    }

    $("#form1").submit(function(){
    setCookie("input1", $("#input1").val()); // do this for all inputs
    });


    Page2



    function getCookie(name) {
    var chunks = document.cookie.split(";");
    for(var i=chunks.length; i--;){
    if(chunks[i].trim().split("=")[0].trim() == name){
    return chunks[i].trim().split("=")[1].trim();
    }
    }
    return null;
    }

    $(document).ready(function(){
    $("#input1").val(getCookie("iunput1")); // do the same for the other inputs
    });





    share|improve this answer





















    • Thank you for your help. I have copied the whole of the page 2, after editing the fields. But the page is just blank, do I need to display the values such as an alert?
      – Alice
      Apr 8 '16 at 18:48










    • you have to add your own element id's.. i just made up $("#input1")..
      – Occam's Razor
      Apr 8 '16 at 18:52










    • Yeah I have, thats what I meant when I said 'editing the fields'. The element id's are correct, just nothing is shown. I dont think the elements are being disppalyed
      – Alice
      Apr 8 '16 at 19:00










    • if you have firefox you can check the cookies in the cookies tab in the console, i'm sure it's there for chome too but idk..
      – Occam's Razor
      Apr 8 '16 at 19:04










    • php is the easiest way to go.. are you working on a server?
      – Occam's Razor
      Apr 8 '16 at 19:05















    up vote
    1
    down vote













    As long as the two are on the same domain you can set the data to cookies and repopulate them on the next page..



    Page1



    function setCookie(name, value) {
    var cookie = name + "=" + escape(value) + ";";
    document.cookie = cookie;
    }

    $("#form1").submit(function(){
    setCookie("input1", $("#input1").val()); // do this for all inputs
    });


    Page2



    function getCookie(name) {
    var chunks = document.cookie.split(";");
    for(var i=chunks.length; i--;){
    if(chunks[i].trim().split("=")[0].trim() == name){
    return chunks[i].trim().split("=")[1].trim();
    }
    }
    return null;
    }

    $(document).ready(function(){
    $("#input1").val(getCookie("iunput1")); // do the same for the other inputs
    });





    share|improve this answer





















    • Thank you for your help. I have copied the whole of the page 2, after editing the fields. But the page is just blank, do I need to display the values such as an alert?
      – Alice
      Apr 8 '16 at 18:48










    • you have to add your own element id's.. i just made up $("#input1")..
      – Occam's Razor
      Apr 8 '16 at 18:52










    • Yeah I have, thats what I meant when I said 'editing the fields'. The element id's are correct, just nothing is shown. I dont think the elements are being disppalyed
      – Alice
      Apr 8 '16 at 19:00










    • if you have firefox you can check the cookies in the cookies tab in the console, i'm sure it's there for chome too but idk..
      – Occam's Razor
      Apr 8 '16 at 19:04










    • php is the easiest way to go.. are you working on a server?
      – Occam's Razor
      Apr 8 '16 at 19:05













    up vote
    1
    down vote










    up vote
    1
    down vote









    As long as the two are on the same domain you can set the data to cookies and repopulate them on the next page..



    Page1



    function setCookie(name, value) {
    var cookie = name + "=" + escape(value) + ";";
    document.cookie = cookie;
    }

    $("#form1").submit(function(){
    setCookie("input1", $("#input1").val()); // do this for all inputs
    });


    Page2



    function getCookie(name) {
    var chunks = document.cookie.split(";");
    for(var i=chunks.length; i--;){
    if(chunks[i].trim().split("=")[0].trim() == name){
    return chunks[i].trim().split("=")[1].trim();
    }
    }
    return null;
    }

    $(document).ready(function(){
    $("#input1").val(getCookie("iunput1")); // do the same for the other inputs
    });





    share|improve this answer












    As long as the two are on the same domain you can set the data to cookies and repopulate them on the next page..



    Page1



    function setCookie(name, value) {
    var cookie = name + "=" + escape(value) + ";";
    document.cookie = cookie;
    }

    $("#form1").submit(function(){
    setCookie("input1", $("#input1").val()); // do this for all inputs
    });


    Page2



    function getCookie(name) {
    var chunks = document.cookie.split(";");
    for(var i=chunks.length; i--;){
    if(chunks[i].trim().split("=")[0].trim() == name){
    return chunks[i].trim().split("=")[1].trim();
    }
    }
    return null;
    }

    $(document).ready(function(){
    $("#input1").val(getCookie("iunput1")); // do the same for the other inputs
    });






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Apr 8 '16 at 18:40









    Occam's Razor

    1




    1












    • Thank you for your help. I have copied the whole of the page 2, after editing the fields. But the page is just blank, do I need to display the values such as an alert?
      – Alice
      Apr 8 '16 at 18:48










    • you have to add your own element id's.. i just made up $("#input1")..
      – Occam's Razor
      Apr 8 '16 at 18:52










    • Yeah I have, thats what I meant when I said 'editing the fields'. The element id's are correct, just nothing is shown. I dont think the elements are being disppalyed
      – Alice
      Apr 8 '16 at 19:00










    • if you have firefox you can check the cookies in the cookies tab in the console, i'm sure it's there for chome too but idk..
      – Occam's Razor
      Apr 8 '16 at 19:04










    • php is the easiest way to go.. are you working on a server?
      – Occam's Razor
      Apr 8 '16 at 19:05


















    • Thank you for your help. I have copied the whole of the page 2, after editing the fields. But the page is just blank, do I need to display the values such as an alert?
      – Alice
      Apr 8 '16 at 18:48










    • you have to add your own element id's.. i just made up $("#input1")..
      – Occam's Razor
      Apr 8 '16 at 18:52










    • Yeah I have, thats what I meant when I said 'editing the fields'. The element id's are correct, just nothing is shown. I dont think the elements are being disppalyed
      – Alice
      Apr 8 '16 at 19:00










    • if you have firefox you can check the cookies in the cookies tab in the console, i'm sure it's there for chome too but idk..
      – Occam's Razor
      Apr 8 '16 at 19:04










    • php is the easiest way to go.. are you working on a server?
      – Occam's Razor
      Apr 8 '16 at 19:05
















    Thank you for your help. I have copied the whole of the page 2, after editing the fields. But the page is just blank, do I need to display the values such as an alert?
    – Alice
    Apr 8 '16 at 18:48




    Thank you for your help. I have copied the whole of the page 2, after editing the fields. But the page is just blank, do I need to display the values such as an alert?
    – Alice
    Apr 8 '16 at 18:48












    you have to add your own element id's.. i just made up $("#input1")..
    – Occam's Razor
    Apr 8 '16 at 18:52




    you have to add your own element id's.. i just made up $("#input1")..
    – Occam's Razor
    Apr 8 '16 at 18:52












    Yeah I have, thats what I meant when I said 'editing the fields'. The element id's are correct, just nothing is shown. I dont think the elements are being disppalyed
    – Alice
    Apr 8 '16 at 19:00




    Yeah I have, thats what I meant when I said 'editing the fields'. The element id's are correct, just nothing is shown. I dont think the elements are being disppalyed
    – Alice
    Apr 8 '16 at 19:00












    if you have firefox you can check the cookies in the cookies tab in the console, i'm sure it's there for chome too but idk..
    – Occam's Razor
    Apr 8 '16 at 19:04




    if you have firefox you can check the cookies in the cookies tab in the console, i'm sure it's there for chome too but idk..
    – Occam's Razor
    Apr 8 '16 at 19:04












    php is the easiest way to go.. are you working on a server?
    – Occam's Razor
    Apr 8 '16 at 19:05




    php is the easiest way to go.. are you working on a server?
    – Occam's Razor
    Apr 8 '16 at 19:05












    up vote
    0
    down vote













    Either use a service to store your value or web storage like localStorage pr sessionStorage to save you values from the form on page1.html and fetch them on form2.html to use






    share|improve this answer





















    • Could this not be done by either simple HTML or JS?
      – Alice
      Apr 8 '16 at 18:41










    • Yes. If you provide the piece of JS code your sample html files, we may use web storage to do that
      – Aditya Singh
      Apr 8 '16 at 18:43










    • I don't have any JS, just that form
      – Alice
      Apr 8 '16 at 18:49















    up vote
    0
    down vote













    Either use a service to store your value or web storage like localStorage pr sessionStorage to save you values from the form on page1.html and fetch them on form2.html to use






    share|improve this answer





















    • Could this not be done by either simple HTML or JS?
      – Alice
      Apr 8 '16 at 18:41










    • Yes. If you provide the piece of JS code your sample html files, we may use web storage to do that
      – Aditya Singh
      Apr 8 '16 at 18:43










    • I don't have any JS, just that form
      – Alice
      Apr 8 '16 at 18:49













    up vote
    0
    down vote










    up vote
    0
    down vote









    Either use a service to store your value or web storage like localStorage pr sessionStorage to save you values from the form on page1.html and fetch them on form2.html to use






    share|improve this answer












    Either use a service to store your value or web storage like localStorage pr sessionStorage to save you values from the form on page1.html and fetch them on form2.html to use







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Apr 8 '16 at 18:39









    Aditya Singh

    8,38792750




    8,38792750












    • Could this not be done by either simple HTML or JS?
      – Alice
      Apr 8 '16 at 18:41










    • Yes. If you provide the piece of JS code your sample html files, we may use web storage to do that
      – Aditya Singh
      Apr 8 '16 at 18:43










    • I don't have any JS, just that form
      – Alice
      Apr 8 '16 at 18:49


















    • Could this not be done by either simple HTML or JS?
      – Alice
      Apr 8 '16 at 18:41










    • Yes. If you provide the piece of JS code your sample html files, we may use web storage to do that
      – Aditya Singh
      Apr 8 '16 at 18:43










    • I don't have any JS, just that form
      – Alice
      Apr 8 '16 at 18:49
















    Could this not be done by either simple HTML or JS?
    – Alice
    Apr 8 '16 at 18:41




    Could this not be done by either simple HTML or JS?
    – Alice
    Apr 8 '16 at 18:41












    Yes. If you provide the piece of JS code your sample html files, we may use web storage to do that
    – Aditya Singh
    Apr 8 '16 at 18:43




    Yes. If you provide the piece of JS code your sample html files, we may use web storage to do that
    – Aditya Singh
    Apr 8 '16 at 18:43












    I don't have any JS, just that form
    – Alice
    Apr 8 '16 at 18:49




    I don't have any JS, just that form
    – Alice
    Apr 8 '16 at 18:49










    up vote
    0
    down vote













    You can persist values using local storage. For example, to write a value to storage:



    localStorage.setItem('myValue', someVariable);


    Then, on the next page, fetch that value:



    var someVariable = localStorage.getItem('myValue');


    And when you're done with the value in storage, be sure to remove it:



    localStorage.removeItem('myValue');





    share|improve this answer

























      up vote
      0
      down vote













      You can persist values using local storage. For example, to write a value to storage:



      localStorage.setItem('myValue', someVariable);


      Then, on the next page, fetch that value:



      var someVariable = localStorage.getItem('myValue');


      And when you're done with the value in storage, be sure to remove it:



      localStorage.removeItem('myValue');





      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        You can persist values using local storage. For example, to write a value to storage:



        localStorage.setItem('myValue', someVariable);


        Then, on the next page, fetch that value:



        var someVariable = localStorage.getItem('myValue');


        And when you're done with the value in storage, be sure to remove it:



        localStorage.removeItem('myValue');





        share|improve this answer












        You can persist values using local storage. For example, to write a value to storage:



        localStorage.setItem('myValue', someVariable);


        Then, on the next page, fetch that value:



        var someVariable = localStorage.getItem('myValue');


        And when you're done with the value in storage, be sure to remove it:



        localStorage.removeItem('myValue');






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 8 '16 at 19:09









        David

        144k26143207




        144k26143207






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36506851%2fjavascript-form-variables%23new-answer', 'question_page');
            }
            );

            Post as a guest




















































































            Popular posts from this blog

            How to pass form data using jquery Ajax to insert data in database?

            National Museum of Racing and Hall of Fame

            Guess what letter conforming each word