Hi,
I have a textbox(txtamt) to enter some amount(decimal value)
In the next textbox(txtpercentage) i am asking user to enter some percentage and in another textbox(txtvalue) i have to calculate the percentage value for the amount entered .. Like suppose if user enters 100 as amount and 1% so in the 3rd text box i will be showing 1 which is the calculated value for 1% on 100 amount. Similarly when user enters some other percentage for the same amount how do i calculate it.. I mean at what event should i write the calculation.. ?
That's not possible. There's no such event that causes postback on keypress.
Though it can be done via javascript it will be very bad user interface plus too heavy.
I will suggest to use javascript and jQuery for calculations.
Sir
if it is possible in javascript how to do that?
Try this
HTML
<input type="text" id="text1" /><input type="text" id="text2" /><input type="text" id="text3" />
jqury
<script type ="text/javascript"> $(document).ready(function () { $(":text").live("keyup", function () { $("#text3").val($("#text1").val()*$("#text2").val()); }); }); </script>
Check this
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript"> function KeyUp(txt2) { var txt1 = document.getElementById("<%=TextBox1.ClientID %>"); var txt3 = document.getElementById("<%=TextBox3.ClientID %>"); var value = parseInt(txt1.value) * parseInt(txt2.value); txt3.value = "0"; if (!isNaN(value)) { txt3.value = value; } } </script> </head> <body> <form id="form1" runat = "server"> Value: 1<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> Value: 2<asp:TextBox ID="TextBox2" runat="server" onkeyup = "KeyUp(this)" ></asp:TextBox> Result:<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> </form> </body> </html>
Sir,
Thank u very much.. This is exactly what i was asking u.. In the KeyUp function how to pass textbox which is in gridview?
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.