TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Pass Data One page to other Page using HTML
Jithil John
Sep 22
2015
Code
1.1
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
Page1.html
<html>
<body>
<form>
<script type=
"text/javascript"
src=
"http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"
></script>
Name:
<input type=
"text"
id=
"txtName"
name=
"Name"
value=
"Jithil John"
/>
<br />
<br />
<input type=
"button"
id=
"btnQueryString"
value=
"Send"
/>
<script type=
"text/javascript"
>
$(function() {
$(
"#btnQueryString"
).bind(
"click"
, function() {
var url =
"Page2.htm?name="
+ encodeURIComponent($(
"#txtName"
).val());
window.location.href = url;
});
});
</script>
<br />
</form>
</body>
</html>
Page2.html
<html>
<body>
<form id=
"form1"
>
<script type=
"text/javascript"
src=
"http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"
></script>
<script type=
"text/javascript"
>
var queryString =
new
Array();
$(function() {
if
(queryString.length == 0) {
if
(window.location.search.split(
'?'
).length > 1) {
var
params
= window.location.search.split(
'?'
)[1].split(
'&'
);
for
(var i = 0; i <
params
.length; i++) {
var key =
params
[i].split(
'='
)[0];
var value = decodeURIComponent(
params
[i].split(
'='
)[1]);
queryString[key] = value;
}
}
}
if
(queryString[
"name"
] !=
null
) {
var data =
"<b>Name:</b> "
+ queryString[
"name"
];
$(
"#lblData"
).html(data);
}
});
</script>
<span id=
"lblData"
></span>
</form>
</body>
</html>
HTML
Pass Data One page to other Page
Query String