This topic is locked

Calculating fields

7/27/2009 6:30:35 PM
ASPRunnerPro General questions
T
Tempus_Erus author

Hi,
I need to calculate 2 fields.
Fields exist in database.
I have tried the below:
use Before record added/updated events on the Events tab to calculate values and fill field.

Here is a sample:

QUOTE
dict("FieldName1") = dict("FieldName2")*dict("FieldName3")
I need to add totals on the fly to my add page, edit page etc etc.
What am I doing wrong as I can't get this to work?
eg.

  1. use Before record added/updated events on the Events tab to calculate values and fill field.

    Here is a sample:
    dict("Total") = dict("pricepermile")*dict("miles")
    Any help is appreciated.
    TE

J
Jane 7/28/2009
T
Tempus_Erus author 7/30/2009

Hi,

please check this thread:

http://www.asprunner.com/forums/index.php?showtopic=12339


Jane - Thanks for that. I have tried the below:
<html>

<head><title>JAVA TEST</title>

<link REL="stylesheet" href="include/style.css" type="text/css">

{$includes}

<script language=javascript>

var x = document.forms._Table1_list.value_Field_1.value;

var y = document.forms._Table1_list.value_Field_2.value;

x.onchange=x.onkeyup=y.onchange=y.onkeyup=function()

{

var Field_1= document.forms._Table1_list.value_Field_1.value;

var Field_2= document.forms._Table1_list.value_Field_2.value;

document.forms._Table1_list.value_SUB_TOTAL.value = Field_1.toFixed()+Field_2.toFixed();

}

</script>

</head>
<body bgcolor=white {$bodyonload}>

{if !$onthefly}
etc etc ect
but i get an error :
'document.forms._Table1_list_Field_1' is null or not an object.
I have checked the path made sure that all spelling is right regards being case sensative etc etc.
What could I be doing wrong. As a newbie it's probably an obvious newbie mistake!
Any help is appreciated.

J
Jane 7/30/2009

Hi,
add this code at the end of the page, just after </HTML> tag.

T
Tempus_Erus author 7/30/2009

Thanks for you patience!!
I can't get the script to work.
When I upload from Asprunner the altered code does not appear.
Have tried placing the code in .htm file and the .asp file using Dreamweaver.
I have created a very simple 'test' at http://demo.asprunner.net/info_ams_solutio...st.asp?a=return.
Would appreciate any step by step guide.
This is the Java Script below
<script language=javascript>

var x = document.forms._Table1_list.value_Field1.value;

var y = document.forms._Table1_list.value_Field2.value;

x.onchange=x.onkeyup=y.onchange=y.onkeyup=function()

{

var Field1= document.forms._Table1_list.value_Field1.value;

var Field2= document.forms._Table1_list.value_Field2.value;

document.forms._Table1_list.value_Sub.value = Field1.toFixed()+Field2.toFixed();

}

</script>
Once again any help is appreciated.

J
Jane 7/31/2009

Hi,
you should add this code on the Visual Editor tab in HTML mode on the add/edit pages.

Also please make sure result field is not set up as readonly.

<script>

var x = document.forms._Table1.value_Field1.value;

var y = document.forms._Table1.value_Field2.value;

x.onchange=x.onkeyup=y.onchange=y.onkeyup=function()

{

var Field1= document.forms._Table1.value_Field1.value;

var Field2= document.forms._Table1.value_Field2.value;

document.forms._Table1_list.value_Sub.value = Field1.toFixed()+Field2.toFixed();

}

</script>

T
Tempus_Erus author 7/31/2009

Hi,
I have tried everything and I still can't get the script to work.
Do you have a working example that I can study?
Many thanks once again.

J
Jane 8/3/2009

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.