Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Pop up custom calculator child window with few values

$
0
0

Hi,

I have done a window design code as below and it is a CHILD window that trigger by a button at PARENT form. So now, i am able to return 1 value and set to the parent's text box. How if i wan to pass more value back to the parent text field?  any suggestion?

Here the code for parent window

 protected void Page_Load(object sender, EventArgs e)
        {
            string cal = @"PopUp('Calculator.aspx?ctrl=ctl00_PlaceHolderMain_txtProposeAir')";

            this.btnCal.Attributes.Add("onclick", cal);
}

Here the code for Child window

<script type="text/javascript">

        function close()
        {
            window.close();
        }

        function DHLupdateParent()
        {
            var total= document.getElementById('<%= txtDHLTotal.ClientID%>').value;
            window.opener.document.getElementById('<%= Request["ctrl"] %>').value = total;
            //return total;
            //window.close();
        }

        function TNTupdateParent() {
            var total = document.getElementById('<%= txtTNTTotal.ClientID%>').value;
            window.opener.document.getElementById('<%= Request["ctrl"] %>').value = total;
            //return total;
           // window.close();
        }

        function TNTTotal(fuleSurchage)
        {
            document.getElementById('<%= txtTNTTotal.ClientID%>').value = fuleSurchage + parseFloat(document.getElementById('<%= txtTNTRate.ClientID%>').value) + parseFloat(document.getElementById('<%= txtTNTSecurityCharge.ClientID%>').value);
        }

        function tntfuleSurchage(tntSecurityCharge)
        {
            var securityCharge = parseFloat(document.getElementById('<%= txtTNTSecurityCharge.ClientID%>').value);
            var importCharge = parseFloat(document.getElementById('<%= txtTNTImportCharge.ClientID%>').value);
            var Rate = parseFloat(document.getElementById('<%= txtTNTRate.ClientID%>').value);
            var fuleSurchageRate = parseFloat(document.getElementById('<%= txtTNTFuleRate.ClientID%>').value);

            var fuleSurchage = (securityCharge + importCharge + Rate) * fuleSurchageRate / 100;
            document.getElementById('<%= txtTNTFuleCharge.ClientID%>').value = fuleSurchage;
            TNTTotal(fuleSurchage);

        }

        function tntSecurityCharge()
        {
            var weight = parseFloat(document.getElementById('<%= txtTNTWeight.ClientID%>').value);
            var rate = parseFloat(document.getElementById('<%= txtTNTSecurityRate.ClientID%>').value);

            document.getElementById('<%= txtTNTSecurityCharge.ClientID%>').value = rate * weight;
            tntfuleSurchage(rate * weight);
        }

        function ComputeCosts(dhlfuleSurchage)
        {
            var dhlrate = parseFloat(document.getElementById('<%= txtDHLRate.ClientID%>').value);

            document.getElementById('<%= txtDHLTotal.ClientID%>').value = dhlrate + dhlfuleSurchage;
        }

        function dhlfuleSurchage()
        {
            var fuleRate = parseFloat(document.getElementById('<%= txtDHLFuleRate.ClientID%>').value);
            var dhlrate = parseFloat(document.getElementById('<%= txtDHLRate.ClientID%>').value);

            var surcharge = parseFloat(document.getElementById('<%= txtDHLFule.ClientID%>').value = fuleRate * dhlrate / 100);
            ComputeCosts(surcharge);
        }</script><form id="form1" runat="server"><div><fieldset><legend>DHL</legend><table width="100%"><tr><td>Weight (KG)</td><td><asp:TextBox runat="server" ID="txtDHLWeight" Text="0.00"/></td></tr><tr><td>Rate</td><td><asp:TextBox runat="server" onkeyup="ComputeCosts();" Text="0.00" ID="txtDHLRate" /></td></tr><tr><td>Fule Surcharges</td><td><asp:TextBox runat="server" onkeyup="dhlfuleSurchage();" Text ="0.00" Enabled="false" ID="txtDHLFule" /></td><td>Current Fule Rate</td><td><asp:TextBox runat="server" onkeyup="dhlfuleSurchage();" Text="0.00" ID="txtDHLFuleRate" /></td></tr><tr><td>Total (RM)</td><td><asp:TextBox runat="server" ID="txtDHLTotal" Text="0.00" /></td></tr><tr><td><asp:Button ID="Proposed" runat="server" Text="Button" OnClientClick="javascript:DHLupdateParent();" /></td></tr></table></fieldset><fieldset><legend>TNT</legend><table width="100%"><tr><td>Weight (KG)</td><td><asp:TextBox runat="server" ID="txtTNTWeight" Text="0.00" onkeyup="tntSecurityCharge();"/></td></tr><tr><td>Rate</td><td><asp:TextBox runat="server" ID="txtTNTRate" Text="0.00" /></td></tr><tr><td>Import Charges</td><td><asp:TextBox runat="server" Text="0.00" ID="txtTNTImportCharge" /></td></tr><tr><td>Security Charges</td><td><asp:TextBox runat="server" Text="0.00" ID="txtTNTSecurityCharge" onkeyup="tntSecurityCharge();" /></td><td>Charge Rate/KG</td><td><asp:TextBox runat="server" ID="txtTNTSecurityRate" Text="0.21" /></td></tr><tr><td>Fuel Surcharges</td><td><asp:TextBox runat="server" Text="0.00" ID="txtTNTFuleCharge" Enabled="false" /></td><td>Current Fule Rate</td><td><asp:TextBox runat="server" ID="txtTNTFuleRate" Text="0.00" onkeyup="tntfuleSurchage();" /></td></tr><tr><td>Total (RM)</td><td><asp:TextBox runat="server" Text="0.00" ID="txtTNTTotal" /></td></tr><tr><td><asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javascript:TNTupdateParent();" /></td></tr></table></fieldset><table><tr><td><asp:Button ID="Button2" runat="server" Text="Button" OnClientClick="javascript:close();" /></td></tr></table></div></form>

Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>