Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8688609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:24:48+00:00 2026-06-12T23:24:48+00:00

Suppose I have 2 html files: form.html and confirm.html form.html just have a text

  • 0

Suppose I have 2 html files: form.html and confirm.html

form.html just have a text field and a submit button, when you hit submit it will display what you just typed in text field.

    <HTML>
      <HEAD>
        <TITLE>Test</TITLE>
        <script type="text/javascript"> 

        function display(){ 
            document.write("You entered: " + document.myform.data.value);
        } 
        </script> 
      </HEAD>
      <BODY>
      <center>    
<form name="myform">

  <input  type="text" name="data">
  <input type="submit" value="Submit" onClick="display()">

</form>
    </BODY>
    </HTML>

Now I want that when hit submit button it will display entered value in confirm.html. What should I do? I mean what should be in confirm.html and how data from form.html be used in other location, do I need create a separate JavaScript file to store JS function so I can use it in both 2 html files. I am kind of new to all kind of stuff.

Note: No PHP or server side language or anything super here, just 2 html files in my Desktop and I want to test using FireFox.

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:24:49+00:00Added an answer on June 12, 2026 at 11:24 pm

    You can try using localStorage or cookies. Check one of the 2 solutions found below…

    1 – If you have HTML5, you can store the content of you input into the localStorage.

    Try this example:

    form.html:

    <html>
    <head>
        <title>Test</title>
        <script type="text/javascript">
    
            // Called on form's `onsubmit`
            function tosubmit() {
                // Getting the value of your text input
                var mytext = document.getElementById("mytext").value;
    
                // Storing the value above into localStorage
                localStorage.setItem("mytext", mytext);
    
                return true;
            }
    
        </script> 
    </head>
    <body>
        <center>   
            <!-- INLCUDING `ONSUBMIT` EVENT + ACTION URL --> 
            <form name="myform" onsubmit="tosubmit();" action="confirm.html">
    
                <input  id="mytext" type="text" name="data">
                <input type="submit" value="Submit">
    
            </form>
    </body>
    </html>
    

    confirm.html:

    <html>
    <head>
    <script>
    
        // Called on body's `onload` event
        function init() {
            // Retrieving the text input's value which was stored into localStorage
            var mytext = localStorage.getItem("mytext");
    
            // Writing the value in the document
            document.write("passed value = "+mytext);
        }
    
    </script>
    </head>    
    
    <body onload="init();">
    
    </body>
    
    </html>
    

    2 – Also, as @apprentice mentioned, you can also use cookies with HTML standards.

    Try this example:

    form.html:

    <html>
    <head>
        <title>Test</title>
        <script type="text/javascript">
            // Function for storing to cookie
            function setCookie(c_name,value,exdays)
            {
                var exdate=new Date();
                exdate.setDate(exdate.getDate() + exdays);
                var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
                document.cookie=c_name + "=" + c_value;
            }
    
            // Called on form's `onsubmit`
            function tosubmit() {
                // Getting the value of your text input
                var mytext = document.getElementById("mytext").value;
    
                // Storing the value above into a cookie
                setCookie("mytext", mytext, 300);
    
                return true;
            }
    
        </script> 
    </head>
    <body>
        <center>   
            <!-- INLCUDING `ONSUBMIT` EVENT + ACTION URL --> 
            <form name="myform" onsubmit="tosubmit();" action="confirm.html">
    
                <input  id="mytext" type="text" name="data">
                <input type="submit" value="Submit">
    
            </form>
    </body>
    </html>
    

    confirm.html:

    <html>
    <head>
    <script>
    
        // Function for retrieveing value from a cookie
        function getCookie(c_name)
        {
            var i,x,y,ARRcookies=document.cookie.split(";");
            for (i=0;i<ARRcookies.length;i++)
            {
                x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
                y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
                x=x.replace(/^\s+|\s+$/g,"");
                if (x==c_name)
                {
                    return unescape(y);
                }
            }
        }
    
        // Called on body's `onload` event
        function init() {
            // Retrieving the text input's value which was stored into a cookie
            var mytext = getCookie("mytext");
    
            // Writing the value in the document
            document.write("passed value = "+mytext);
        }
    
    </script>
    </head>    
    
    <body onload="init();">
    
    </body>
    
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have the following HTML: <form id=myform> <input type='checkbox' name='foo[]'/> Check 1<br/> <input
Suppose I have the following HTML: <div id=test> <span style=display:inline;>foo</span> <span style=display:none;>bar</span> <span style=display:inline;>baz</span>
Suppose you're building an HTML form and you want to have 2 or more
I have a HTML table inside which I have a submit button. Now, I
Suppose I have an HTML page with three blocks of fixed width (their height
Suppose I have this html markup: <div id=wrapper> <pre class=highlight> $(function(){ // hide all
Suppose we have this html content, and we are willing to get Content1, Content2,..
A newbie question,really. Suppose I have a html table like this: <div id=div1> <table
Suppose I have the following html: This a test of <code>some code</code>. <div class='highlight'>
Suppose we have this example: http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html with source code available here: http://code.google.com/p/myandroidwidgets/source/browse/trunk/Phonebook/src/com/abeanie/ How can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.