473,503 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Client-side calculation without postback

Hi,

I am trying to figure out how to do a client-side calculation based on
textbox values, using asp.net, without performing a postback.

I have 2 textboxes...

<asp:textbox runat="server" CssClass="ddclass" ID="txtTotal"
onBlur="calculate()" />

<asp:textbox runat="server" CssClass="ddclass" ID="txtAmount" />
I have used the following Javascript code...

<SCRIPT TYPE="text/javascript">
<!--
function calculate() {
var Amount;
Amount = (document.forms["_ctl0"].elements[5].value * 0.075);
Amount = CovCom.toFixed(2);
document.forms["_ctl0"].elements[6].value = Amount;

};
-->
</script>

However, sometimes the element number changes, and calculation does not
occur. Is there a way of referring to the textbox ID's in the Javscript
code?

Has anyone performed client-side calculations in asp.net without
postback? Is there a better way than doing the above?

Appreciate any help!!

Thanks,

John.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #1
1 4639
Hi,

you can out the the generated ID from code by using txtTotal.ClientID
property of the control and outputting it to the script (either generate
entire script block in code or append tthe id using <%=txtTotal.ClientID%>
block in middle of the script.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU

"John Mason" <wo*********@hotmail.com> wrote in message
news:us**************@TK2MSFTNGP09.phx.gbl...
Hi,

I am trying to figure out how to do a client-side calculation based on
textbox values, using asp.net, without performing a postback.

I have 2 textboxes...

<asp:textbox runat="server" CssClass="ddclass" ID="txtTotal"
onBlur="calculate()" />

<asp:textbox runat="server" CssClass="ddclass" ID="txtAmount" />
I have used the following Javascript code...

<SCRIPT TYPE="text/javascript">
<!--
function calculate() {
var Amount;
Amount = (document.forms["_ctl0"].elements[5].value * 0.075);
Amount = CovCom.toFixed(2);
document.forms["_ctl0"].elements[6].value = Amount;

};
-->
</script>

However, sometimes the element number changes, and calculation does not
occur. Is there a way of referring to the textbox ID's in the Javscript
code?

Has anyone performed client-side calculations in asp.net without
postback? Is there a better way than doing the above?

Appreciate any help!!

Thanks,

John.

*** Sent via Developersdex http://www.developersdex.com ***

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
4449
by: Michael Rybak | last post by:
hi, everyone. I'm writing a 2-players game that should support network mode. I'm now testing it on 1 PC since I don't have 2. I directly use sockets, and both client and server do...
2
3017
by: Raquel | last post by:
How do I know whether the 'runtime client' and the 'application development client' are installed on my machine? When I issue the command "db2licm -l", it gives the following output: Product...
2
4644
by: Rhino | last post by:
I am trying to verify that I correctly understand something I saw in the DB2 Information Center. I am running DB2 Personal Edition V8.2.1 on Windows. I came across the following in the Info...
0
2153
by: Harley | last post by:
Hello, I am just learning the tcp/ip functions etc under vb.net so please look over me if this is obviouse. I have been all over looking into any functions that I didn't totaly understand and...
8
2720
by: Ankit Aneja | last post by:
i am doing here some some socket-client work in C# windows service it is working fine for multiple clients now i want to limit these multiple clients to 25 for example i want that when service...
2
1971
by: Delmar | last post by:
I need to build Web Application that will generate a client to execute some operations. Each client has running silent application. Maybe somebody can advice me what can I do ? Thank you.
14
4427
by: Ankit Aneja | last post by:
The code of classes given below is for server to which clients connect i want to get ip address of client which has connected pls help how can i get //listen class public class listen {
0
1715
by: khu84 | last post by:
Here is client server very simple code, seems to work with telnet but with with web client code gives blank output. Following is the server code:- <?php function...
2
4083
by: nsaffary | last post by:
hi I hava a client/server program that run correctly when i run it in one computer(local) but when I run client on a one computer and run server run on another, connection does not stablish.(I set...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.