user1666698
user1666698

Reputation: 51

Get data with jQuery

I have two text fields on different pages. One text field with the id ais on page 1 and second text field with the id b is on page 2. I want to know how can I get data from 1st text field and put it into 2nd text field with jQuery.

Upvotes: 0

Views: 77

Answers (1)

Konstantin Dinev
Konstantin Dinev

Reputation: 34895

You need to transfer the value from one page to the other when navigating. You can do this via url parameters and you can access them via the URL.

Here's an example: Page 1 HTML:

<a id="link" href="#">Link</a>
<input type="text" id="a" value="some value" />

Page 1 JS:

$('#link').click(function (event) {
    $(this).attr('href', 'page2.html?text=' + $('#a').val());
});

Page 2: Refer to this post on how to extract the URL parameter.

Upvotes: 1

Related Questions