I have two text fields on different pages. One text field with the id a
is 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.
Asked
Active
Viewed 74 times
0

Usman
- 3,200
- 3
- 28
- 47

user1666698
- 51
- 5
-
is page 2 , an User control which is being embedded in page 1.. It will be accessible straight away if you have the same case? – Dhanasekar Murugesan Oct 08 '12 at 06:51
-
Is page 2 being opened using `window.open()` from page 1? Or is there absolutely no link between them? – Kristof Claes Oct 08 '12 at 06:53
-
Here is my code: jQuery(document).ready(function() {jQuery('#b').value(jQuery("#a")); }); – user1666698 Oct 08 '12 at 06:56
-
There is no link betweeen the pages. @KristofClaes – user1666698 Oct 08 '12 at 07:01
-
If there is no link between the pages, I don't think you can make it work without using some sort of server technology like SignalR. – Kristof Claes Oct 08 '12 at 07:05
-
Your question is pretty generalist, there's very much ways for do this and all of them are strongly related with the server-structure you're using. Is it a php server? a Java server?. But generally speaking, like Konstantin D says, you must pass it through POST or GET and read it in the other side. – jlledom Oct 08 '12 at 07:15
1 Answers
1
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.

Community
- 1
- 1

Konstantin Dinev
- 34,219
- 14
- 75
- 100