This topic is locked

How to calculate values on the fly

5/7/2010 6:36:09 PM
ASPRunnerPro Tips and tricks
admin

Let's say there are three fields on the add/edit page: Price, Quantity and Total. To calculate total value on the fly use JavaScript code (add it at the end of the page on the Visual Editor tab in HTML mode).

Here is a sample code for ASPRunnerPro 6.1:

<script>

document.forms.editform.value_Price.onchange = document.forms.editform.value_Quantity.onchange = function()

{

document.forms.editform.value_Total.value = document.forms.editform.value_Price.value*document.forms.editform.value_Quantity.value;

}

</script>



and for ASPRunnerPro 6.2. Add this code to 'Javascript OnLoad' event of the page where you need this calculation to happen:



var ctrlPrice = Runner.getControl(pageid, 'Price');

var ctrlQuantity = Runner.getControl(pageid, 'Quantity');

var ctrlTotal = Runner.getControl(pageid, 'Total');
function func() {

ctrlTotal.setValue(parseFloat(ctrlPrice.getValue()) * parseFloat(ctrlQuantity.getValue()));

};
ctrlPrice.on('keyup', func);

ctrlQuantity.on('keyup', func);
U
ultra999 6/2/2010

ERROR OCCURED

see below message (Error Code)
--------------------------------------------------------
HTTP 500.100 - 내부 서버 오류 - ASP 오류

인터넷 정보 서비스
오류 형식:

Microsoft VBScript 컴파일 오류 (0x800A0409)

종결되지 않은 문자열 상수입니다.

/test/include/aspfunctions.asp, line 2701
---------------------------------------------------------

This is my code in Javascript OnLoadEvent

'# code start

var ctrlTotalSale = Runner.getControl(pageid, 'TotalSale');

var ctrlCashSale = Runner.getControl(pageid, 'CashSale');

var ctrlCardSale = Runner.getControl(pageid, 'CardSale');
function func() {

ctrlTotalSale.setValue(parseFloat(ctrlCashSale.getValue()) + parseFloat(ctrlCardSale.getValue()));

};
ctrlCashSale.on('keyup', func);

ctrlCardSale.on('keyup', func);

'# code end
This is javascript code

'# Code Start

<script>document.forms.editform1.value_CashSale_1.onchange = document.forms.editform1.value_CardSale_1.onchange = function()

{ document.forms.editform1.value_TotalSale_1.value = document.forms.editform1.value_CashSale_1.value + document.forms.editform1.value_CardSale_1.value ; } </SCRIPT>

'# code end

admin 6/2/2010

Error 500 means it's happening on the server side (in ASP) code while you adding Javascript code. Most probably this error is not related to the code above.
I recommend to post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.