If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > how to calculate....help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-06-04, 00:34
ayien8180 ayien8180 is offline
Registered User
 
Join Date: May 2004
Posts: 4
Unhappy how to calculate....help

i have problem now with my calculation..i have 4 textfield what i want is to add first,second and third textfield and total of this 3 appear in textfield number 4

example

textfield 1 + textfield 2 + textfield 3 = textfield 4


plzzzzzzzzzzzzz i'm new in asp
Reply With Quote
  #2 (permalink)  
Old 05-06-04, 02:41
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
Sounds like you want JavaScript instead of ASP. Do you want textfield1, textfield2, and textfield3 to sum and update textfield4 dynamically, or do you expect this to sum on the refresh of the page?

In JS it'd be:
Code:
<script language="javascript">
<!--
function updateTextField(){
  if(!isNaN(document.myform.textfield1.value) && !isNaN(document.myform.textfield2.value) && !isNaN(document.myform.textfield3.value)){
    document.myform.textfield4.value = Number(document.myform.textfield1.value) + Number(document.myform.textfield2.value) + Number(document.myform.textfield3.value);
  }
}
//-->
</script>

<form name="myform">
  <input name="textfield1" type="text" onChange="updateTextField();"><BR>
  <input name="textfield2" type="text" onChange="updateTextField();"><BR>
  <input name="textfield3" type="text" onChange="updateTextField();"><BR>
  <input name="textfield4" type="text" READONLY><BR>
</form>
In ASP (test.asp) it'd be:
Code:
<form action="test.asp?Update=1" method="post">
  <input name="textfield1" type="text"><BR>
  <input name="textfield2" type="text"><BR>
  <input name="textfield3" type="text"><BR>
</form>
<%
If CInt(Trim(Request.QueryString("Update"))) = 1 Then
  Dim iSumFields
  iSumFields = CInt(Trim(Request.Form("textfield1")))
  iSumFields = iSumFields + CInt(Trim(Request.Form("textfield2")))
  iSumFields = iSumFields + CInt(Trim(Request.Form("textfield3")))
  
  Response.Write "Value: " & iSumFields & "<BR>"
End If
%>
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
  #3 (permalink)  
Old 05-06-04, 03:10
ayien8180 ayien8180 is offline
Registered User
 
Join Date: May 2004
Posts: 4
thnak you

thank you...my problem is already solve .... i use the java script....because when i use asp have a problem....thank u very much
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On