RE: display running total using all client side code
- From: Paul <Paul@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 22 Oct 2008 10:36:27 -0700
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.
- References:
- display running total using all client side code
- From: Paul
- RE: display running total using all client side code
- From: bruce barker
- display running total using all client side code
- Prev by Date: RE: Installing ASP.Net SQL Session State on IIS7
- Next by Date: Get data from Local Web.config not machine.config
- Previous by thread: RE: display running total using all client side code
- Next by thread: Can this be done and if so how?
- Index(es):
Relevant Pages
|