Passing data between a parent window and a child popup window with jQuery

前端 未结 3 1056
滥情空心
滥情空心 2020-12-15 07:49

I have the following HTML


    
        Affiliate Party
    
    
            


        
3条回答
  •  情话喂你
    2020-12-15 08:12

    Script on parent page:

    $(".PartyLookupToggle").click(function () {
        var id = $(this).prev().prev().attr("id");
        var name = $(this).prev().attr("id");
    
        var url = "PartySearch.aspx?id=" + id + "&name=" + name;
    
        window.open(url, "PartySearch", "width=400,height=50");
        return false;
    });
    

    Script on child page:

    // Get the values from the URL using the jquery.query plug-in
    var id = $.query.get("id");
    var name = $.query.get("name");
    
    // Get the values from the drop down
    var newPartyId = $("#ddlMatchingParties").val();
    var newPartyName = $("#ddlMatchingParties option:selected").text();
    
    // Set them to the parent window
    window.opener.$("#" + id).val(newPartyId);
    window.opener.$("#" + name).val(newPartyName);
    
    // Close the popup
    window.close();
    

提交回复
热议问题