How to pass values between pages using jquery [Resolved]

Posted by Klbaiju under jQuery on 11/19/2015 | Points: 10 | Views : 647 | Status : [Member] | Replies : 3
Hi,

I want to pass a value to another page and display value there and load that page using jquery

i tried following code

$('#addr').click(function (e) {
e.preventDefault();
var url = "AddressForm.aspx?stid=" + encodeURIComponent($("#txtstid").val()) + "&clas=" + encodeURIComponent($("#txtclass").val());
// window.location.href = url;
$('#displ').load(url);
});


here i want to display AddressForm.aspx in displ div. and passing 2 texbox values.

i wrote the code for displaying in AddressForm.aspx

as

var queryString = new Array();
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;
alert(value);
}
}
}

$('#astudent').val(queryString["stid"]);
$('#aclass').val(queryString["clas"]);


current problem is Addressform.aspx is displaying but no data is displaying in corresponding textboxes.

How to solve this

Regards

Baiju




Responses

Posted by: Lucygrey on: 1/11/2016 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hey,here is the code try this :

JS
$('#page2').live('pageshow', function(event, ui) {
alert('Page 2 - CID: ' + getParameterByName('cid'));
});

function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
HTML
<div data-role="page" id="home">
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="f">
<li data-role="list-divider">
Home Page
</li>
<li>
<a href="?cid=1234#page2" rel="external">Page 2</a>
</li>
</ul>
</div>
</div>
<!-- page 2 -->
<div data-role="page" id="page2">
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="f">
<li data-role="list-divider">
Page 2
</li>
<li>
<a href="?cid=4321#home">Home Page</a>
</li>
</ul>
</div>
</div>




http://www.keenesystems.com/Services/SoftwareDevelopment.aspx

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bhupentiwari on: 11/19/2015 [Member] Starter | Points: 25

Up
0
Down
What is the use by doing this

What exactly you want

Thanks n Regards
Bhupendra Tiwari

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sheonarayan on: 11/20/2015 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Try to see the value of querystrings you are retrieving in jQuery using alert(queryString["stid"]). See if you are getting value. If not, change the method of getting the querystring. Looks like you have problem in getting the querystring values from the url in jQuery or javascript.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response