473,322 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Calculate inside a form and use the same form as Insert record form

I have 3 fields in an aspx page. The 3. field should be the sum of field A
and field B
I use OnTextChanged to calculate the sum in field3.
At the same time I want to insert the content of theese 3 fields into a row
in a table.
The problem is that I need 'postback is true' on the textfields to get an
immediate calculation and then the insert action is triggered.
reidarT
Nov 30 '06 #1
2 1518
Hey reidar,

You don't have to do the postback thing. You can use some javascript
to achieve the same result.

Say you have three textboxes:

txtFirst,txtSecond,txtSum

To get txtSum to be calculated do the following:

In the aspx html code add the following function

<script language=javascript>
function check(){
if(parseInt(document.getElementById('txtFirst').va lue,10)!="NaN" &&
parseInt(document.getElementById('txtSecond').valu e,10)!="NaN"){
document.getElementById('txtSum').value =
parseInt(document.getElementById('txtFirst').value ,10) +
parseInt(document.getElementById('txtSecond').valu e,10)
}
}
</script>

This is basically some javascript that calculate the sum of the first
two textboxes and stores the result in the third. The 10 argument to
parseInt is not redundant ... if you have a number starting with 0 in
either of the text boxes the javascript engine will think it is an
octal number

Then in your code behind do this:

If Not IsPostBack Then
txtFirst.Attributes.Add("onChange", "check()")
txtSecond.Attributes.Add("onChange", "check()")
End If

On Thu, 30 Nov 2006 19:49:41 +0100, "reidarT" <re****@eivon.nowrote:
>I have 3 fields in an aspx page. The 3. field should be the sum of field A
and field B
I use OnTextChanged to calculate the sum in field3.
At the same time I want to insert the content of theese 3 fields into a row
in a table.
The problem is that I need 'postback is true' on the textfields to get an
immediate calculation and then the insert action is triggered.
reidarT
--

Bits.Bytes.
http://bytes.thinkersroom.com
Nov 30 '06 #2
Reidar,

Doing this with "on text change" is in my idea completely foolish over ASPX.
Beside the advise from Rad, you can have a look what Ajax can do for you.
(Just to experiment, because the advise from Rad is in my idea better).

http://ajax.asp.net/

Cor

"reidarT" <re****@eivon.noschreef in bericht
news:Os**************@TK2MSFTNGP02.phx.gbl...
>I have 3 fields in an aspx page. The 3. field should be the sum of field A
and field B
I use OnTextChanged to calculate the sum in field3.
At the same time I want to insert the content of theese 3 fields into a
row in a table.
The problem is that I need 'postback is true' on the textfields to get an
immediate calculation and then the insert action is triggered.
reidarT

Dec 1 '06 #3

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

Similar topics

2
by: Asad | last post by:
I have a form on a page that has several textareas, and textboxes inside a table (so the table containing the textboxes is also inside the FORM tag). I want to replace the textareas with simple...
4
by: Tim Marshall | last post by:
This is an embarrassing question to which I should know the answer, but I am not 100% sure of myself. My applications, whether they are Jet or Oracle usually deal with reporting on existing apps...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
1
by: SorboPos | last post by:
Hi. I have a form with continuous forms and a data entry section in the header of the form. (I.e. all transactions show in the main form area like a data sheet and the data for the highlighed...
2
by: John R. Lewis | last post by:
I posted this yesterday with a different email address. I am reposting with my fake-address as given to me by Microsoft so that I can be guraranteed a response from a support representative. Sorry...
4
by: Mayhem05 | last post by:
I'm hoping someone can guide me on solving this vexing problem I have with a database I built to track a projects. I'm using MS Access 2003 and here are the basics: the database is designed to...
6
by: luanhoxung | last post by:
dear all!! i met the headache problem in setting value for some controls in my form. i have 2 combo box in form F1. i want to set value for some textbox in F1 when i choose value from 2 combo...
1
by: Muchach | last post by:
Hello, Ok so what I've got going on is a form that is populated by pulling info from database then using php do{} to create elements in form. I have a text box in each table row for the user to...
14
by: raylopez99 | last post by:
KeyDown won't work KeyPress fails KeyDown not seen inspired by a poster here:http://tinyurl.com/62d97l I found some interesting stuff, which I reproduce below for newbies like me. The main...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.