How can I get a value from a form in page 1 to another page by using JavaScript?
NickName:ShreYas Vairagi Ask DateTime:2019-04-29T01:16:34

How can I get a value from a form in page 1 to another page by using JavaScript?

I have only learned HTML, CSS, JavaScript and jQuery and I want to get a value from my form to my index page, which is located in different files, using the languages I know. So this is my form :

<form action="../index/index.html" method="GET">
  <label for="name">Name :</label>
  <input type="text" name="name" id="name" required>
  <label for="email">Email :</label>
  <input type="text" name="email" id="email" placeholder="[email protected]" required>
  <input type="submit" name="submit" id="submit">
</form>

I want the value that a user submits in the #name input in my index's div tag when the submit button is pressed (this div has the class sing-in).

Both pages have their own JavaScript and CSS so if I would import the JavaScript of the page where the form is to my index pages it will mess up both pages I guess. Therefore, I want to do this without importing the JavaScript and just by taking the value from another page into my index page. Thank you.

Copyright Notice:Content Author:「ShreYas Vairagi」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/55892728/how-can-i-get-a-value-from-a-form-in-page-1-to-another-page-by-using-javascript

Answers
Wendelin 2019-04-28T17:25:45

When you submit your form and get redrected to your index page the values of the form will be put at the end of the url as GET parameters.\n\nExample url: localhost:80/index/index.html?name=Eddie&[email protected]\n\nTo read the GET parameters you can use this code:\n\nvar urlString = window.location.href\nvar url = new URL(urlString);\nvar name = url.searchParams.get(\"name\");\nvar email = url.searchParams.get(\"email\");\n//Check if name and email are set\n\n\nMake sure to check if name and email have actually been set in index.html",


More about “How can I get a value from a form in page 1 to another page by using JavaScript?” related questions

How can I get a value from a form in page 1 to another page by using JavaScript?

I have only learned HTML, CSS, JavaScript and jQuery and I want to get a value from my form to my index page, which is located in different files, using the languages I know. So this is my form : ...

Show Detail

How can I get post value from current page if my form action point to another page?

I want to get post values from current page while my form action is pointing to another page. Below is code sample: &lt;form id="form1" name="form1" action='page2.php' method="post"&gt; &lt;

Show Detail

Refresh a page(1st page) from another page (3rd page) using javascript

To reload/refresh a page from another page using JavaScript. (A page, which is already opened in the browser. I need to refresh it (not open again) from another page.) I refer a lot, but i can't g...

Show Detail

How to pass an a value from a page to another using javascript

How do you pass a value or an array from one page to another in html using javascript. I'm not allowed to use local storage or sessions only pass the variable from page to page. I'm sending values ...

Show Detail

How can i get that value in html from one page to another page

I want to check password field value after submiting the form by post method. How can I get that value in HTML page using javascript Example: &lt;form method="post" action="check.html"&gt; &

Show Detail

How to get data from a form in another page (JavaScript)

My English is not good enough so I hope you understand what's my problem... I have a page 'A' with a form. When I click Submit, I want it to open/redirect to a page 'B', and I want to show on page...

Show Detail

how can i get single value at next page from multiple values in another page using php

there are 3 JavaScript functions and each function contain a single table name in one page and i am calling any one function at single time.. how can i get that table name in another

Show Detail

how to submit value to another page without using form tag [JAVASCRIPT]

Hii Everyone can help me ? How to submit value to another page without using form tag (method=post), so only using javascript. function runScript(e) { if(e.keyCode==13){ var text=document.

Show Detail

Update a value of a JavaScript variable from another page

Is it possible to update the value of a variable from another page using JavaScript? or Is it possible to do this using form on submit, just update the other page, but remain on the page on which...

Show Detail

How can I pass JavaScript values to another PHP page using an HTML form?

I have spent more than 2 months trying to solve this coding problem. First of all I know JavaScript runs on the client side and PHP runs on server. I have two PHP pages (index23.php and index24.ph...

Show Detail