Client Side Addition

The below code use to add twoo number by the using of JavaScript only.

<script language="javascript" type="text/javascript"

    function Navigate() {       

        var x = document.getElementById("txt1").value;

        var y = document.getElementById("txt2").value;

        var z =parseInt( x )+parseInt( y);

        document.getElementById("txt3").value = z;

    }

</script>

<body>

    <form id="form1" runat="server">

    <div>

        <%-- <asp button type="button" onclick="alert('Welcome!')">Click Me!</button>--%>

        <asp:Button ID="Button1" UseSubmitBehavior="true" Text="Open Web site" OnClientClick="Navigate()"

            runat="server" />

        <asp:TextBox ID="txt1" runat="server"></asp:TextBox>

        <asp:TextBox ID="txt2" runat="server"></asp:TextBox>

        <asp:TextBox ID="txt3" runat="server"></asp:TextBox>

    </div>

    </form>

Ebook Download
View all
Learn
View all