locked
How to pass value and display a page using jquery RRS feed

  • Question

  • User1839056048 posted

    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

    Thursday, November 19, 2015 1:02 AM

Answers

  • User61956409 posted

    Hi Baiju,

    You could try to find the textboxes from container div “displ” and change the values. The following sample is for your reference.

    $("#addr").click(function (e) {
        var url = "AddressForm.aspx";
        $("#displ").load(url).ajaxComplete(function () {
            $("#displ").find("#form1").ready(function () {
                $(this).find("input#astudent").val("stid");
                $(this).find("input#astudent").val("stid");
            });
        });
    
    
    })
    

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 20, 2015 4:47 AM

All replies

  • User-474980206 posted
    An Ajax call does not change the url, you should have the server parse the url passed in $.load and fill in the text boxes.
    Thursday, November 19, 2015 10:22 AM
  • User61956409 posted

    Hi Baiju,

    You could try to find the textboxes from container div “displ” and change the values. The following sample is for your reference.

    $("#addr").click(function (e) {
        var url = "AddressForm.aspx";
        $("#displ").load(url).ajaxComplete(function () {
            $("#displ").find("#form1").ready(function () {
                $(this).find("input#astudent").val("stid");
                $(this).find("input#astudent").val("stid");
            });
        });
    
    
    })
    

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 20, 2015 4:47 AM