473,465 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

display running total using all client side code

Hi I have a webform with several entry boxes and the user enters numbers in
each box. I keep a running total (just adds all of the entries together) but
am posting back to the server to do this. Is there any way to do it all on
the client side, without posting back to the server? I would like to update
the running total each time the user inputs an amount in a textbox and then
goes to the next textbox.
Thanks,
--
Paul G
Software engineer.
Oct 21 '08 #1
3 2082
attach a javascript hander to the onblur event of each textbox. is this
handler add up the textbox values, and display in whatever you are displaying
in:

sample:

// add textbox in InputPanel and put total in last

var panel = document.getElementById('<%= inputPanel.ClientID%>');
var list = panel.getElementsByTagName('input');
var textboxList = [];
for (var i=0; i < list.length - 1; ++i)
{
if (list[i].type.toLowerCase() == 'text')
{
textboxList.push(list[i]);
list[i].onblur = doBlur;
}
}

function doBlur(e) {
var total = 0;
for (var i=0; i < textboxList.length - 1; ++i)
{
total += parseFloat(textboxList[i].value);
}
textboxList[textboxList.length-1].value = total;
}
-- bruce (sqlwork.com)
"Paul" wrote:
Hi I have a webform with several entry boxes and the user enters numbers in
each box. I keep a running total (just adds all of the entries together) but
am posting back to the server to do this. Is there any way to do it all on
the client side, without posting back to the server? I would like to update
the running total each time the user inputs an amount in a textbox and then
goes to the next textbox.
Thanks,
--
Paul G
Software engineer.
Oct 21 '08 #2
thanks for the response. I am really not too good with javascript but just
for clarity what controls as well as the controlnames do I need to put on the
page to work with your example?
--
Paul G
Software engineer.
"bruce barker" wrote:
attach a javascript hander to the onblur event of each textbox. is this
handler add up the textbox values, and display in whatever you are displaying
in:

sample:

// add textbox in InputPanel and put total in last

var panel = document.getElementById('<%= inputPanel.ClientID%>');
var list = panel.getElementsByTagName('input');
var textboxList = [];
for (var i=0; i < list.length - 1; ++i)
{
if (list[i].type.toLowerCase() == 'text')
{
textboxList.push(list[i]);
list[i].onblur = doBlur;
}
}

function doBlur(e) {
var total = 0;
for (var i=0; i < textboxList.length - 1; ++i)
{
total += parseFloat(textboxList[i].value);
}
textboxList[textboxList.length-1].value = total;
}
-- bruce (sqlwork.com)
"Paul" wrote:
Hi I have a webform with several entry boxes and the user enters numbers in
each box. I keep a running total (just adds all of the entries together) but
am posting back to the server to do this. Is there any way to do it all on
the client side, without posting back to the server? I would like to update
the running total each time the user inputs an amount in a textbox and then
goes to the next textbox.
Thanks,
--
Paul G
Software engineer.
Oct 22 '08 #3
Hi, I have it set up with 2 text boxes in the panel and a <input
name="result"/outside of the panel to display the results by using
document.form1.result.value= total in the function doBlur(e). Also for the
two textboxes if have
<input type="text" id="txbx1" onblur="doBlur()" style="position: relative"/>
<input type="text" id="txbx2" onblur="doBlur()" style="position:
relative"/>
Do I need to pass something to doBlur as what is happening now is when I
type any number in the first textbox and then click away (for the onblur
event) The number in both the first text box and my result box is set to 0.
The second text box does not seem to have an effect on anything. Thanks.
--
Paul G
Software engineer.
"bruce barker" wrote:
attach a javascript hander to the onblur event of each textbox. is this
handler add up the textbox values, and display in whatever you are displaying
in:

sample:

// add textbox in InputPanel and put total in last

var panel = document.getElementById('<%= inputPanel.ClientID%>');
var list = panel.getElementsByTagName('input');
var textboxList = [];
for (var i=0; i < list.length - 1; ++i)
{
if (list[i].type.toLowerCase() == 'text')
{
textboxList.push(list[i]);
list[i].onblur = doBlur;
}
}

function doBlur(e) {
var total = 0;
for (var i=0; i < textboxList.length - 1; ++i)
{
total += parseFloat(textboxList[i].value);
}
textboxList[textboxList.length-1].value = total;
}
-- bruce (sqlwork.com)
"Paul" wrote:
Hi I have a webform with several entry boxes and the user enters numbers in
each box. I keep a running total (just adds all of the entries together) but
am posting back to the server to do this. Is there any way to do it all on
the client side, without posting back to the server? I would like to update
the running total each time the user inputs an amount in a textbox and then
goes to the next textbox.
Thanks,
--
Paul G
Software engineer.
Oct 22 '08 #4

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

Similar topics

4
by: Si | last post by:
Hi Guys I am using this code to execute an Access VBA function from ASP: strDbName = strDataSource & "data\webjobs.mdb" Set objAccess = Server.CreateObject("Access.Application")...
4
by: Bill Dika | last post by:
Hi I am trying to calculate a running total of a calculated textbox (tbAtStandard) in GroupFooter1 for placement in a textbox (tbTotalAtStandard) on my report in Groupfooter0. The problem...
5
by: Sue | last post by:
Help! I have an asp table with an embedded table. The asp tablerow that contains this table has a static ID assigned of "FilterRow2" (see snippets of code below). When I click on the button to set...
5
by: GB | last post by:
Okay, here is what I am trying to do We have a dialog of windows that collects information for generation of a dynamic HTML report. The last page in the wizard dialog accepts all report options...
2
by: Davisro | last post by:
I am wondering if it is possible to have a running total of four textboxes so that when any text box is changed I could then calcuate the total of the four boxes and show this on the webform. ...
1
by: Anonieko | last post by:
Query: How to display progress bar for long running page Answer: Yet another solution. REFERENCE: http://www.eggheadcafe.com/articles/20050108.asp My only regret is that when click the...
0
by: brianpmccullough | last post by:
Hello, Anyone ever implemented a solution that allows you to track the total page request time in and ASP.NET page? The time would need to include the server processing time and client side...
3
by: =?Utf-8?B?Um9iZXJ0IENoYXBtYW4=?= | last post by:
Hi, Fairly easy to create one running total for a gridview but what if you have dozens of them? I have a gridview that allows bulk editing (all rows at once) and have it set up so that, on data...
14
by: lmttag | last post by:
Hello. We're developing an ASP.NET 2.0 (C#) application and we're trying to AJAX-enable it. We're having problem with a page not showing the page while a long-running process is executing. So,...
0
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.