This topic is locked

how to grab a value from an html page

11/25/2016 4:33:06 PM
ASPRunner.NET General questions
A
Arkie author

In a Fields Order and Totals page I have assigned a field of a some details records to have a total value for a column. It shows up in HTML as the template language:

{BEGIN qty_showtotal}

Total: {$qty_total}

{END qty_showtotal}

(Which could have been a total, a count or an average)
I would like to have the value of this column total, "Total: {$qty_total}", be copied to a field in the master record that the details list applies to. I'll use it in another calculation.
How do I address this template variable and where do I put the code to grab the value from the details List and then save it to the master record?
TIA... ~Joe

jadachDevClub member 11/25/2016

Maybe use the SQL editor to join on the master table sql. This way the value will be available on the master (read only) for calculation.

A
Arkie author 11/25/2016



Maybe use the SQL editor to join on the master table sql. This way the value will be available on the master (read only) for calculation.


I thought about that and even wrote the query to calculate the total column value I'm looking for. When I started to do the join bit it simply appeared that snagging the template value should be more direct. The Fields and Total page already has the values calculated so why should I re-invent the wheel?
I ran across a post that showed how to get an average and should be a similar method but it's done in PHP and I couldn't duplicate it to work in .net.

admin 11/27/2016

May be you can post that code here and we help you build a C# version of it?

A
Arkie author 11/28/2016



May be you can post that code here and we help you build a C# version of it?



Actually I found two entries with potential, but alas, one was mis-named. They used the word "total" but they were really calculating the "average"

++++

Entry 1 -

you can calculate it manually using custom event on the Events tab. Use List page: Before process to define new session variables, List page: After record processed event to add new value to these sessions (this event is executed for each row) and List page: Before display event to calculate totals and assign it.

Here is a sample List page: Before display event:

$average = $_SESSION["total"]/$_SESSION["number_of_records"];

$xt->assign("custom_total",$average]);

+++++

The next post has the title - "Displaying Child Total on Master List". (This is really what I'm trying to do.) This one was written for ASPRunnner PRO

Entry 2 -

here is the correct code for ASPRunnerPro 6.0:

str = "select sum(Amount)from [Accounts] where [membernum]='" & dict("MemberNum") & "'"
Set rstmp = server.CreateObject("ADODB.Recordset")

rstmp.open str,dbConnection
'update master table

dbConnection.Execute "update [Database] set [Total]=" & rstmp(0) & " where MemberNum='" & dict("MemberNum") & "'"
rstmp.close

set rstmp=nothing

+++++
I fail to understand why I cannot read the value of the template variable - {$qty_total} - once the HTML page is generated or understand how the value is derived so I can calculate it.

~Joe

A
Arkie author 11/28/2016

oh... I thought I'd also post to Jerry's suggestion. The following query works with joined dbs. I just haven't figured out how to get the value I want (invtotal) moved over to the other db...

===

SELECT

invoicedetail.headerid,

SUM(invoicedetail.qtyprice) AS invtotal

FROM invoicedetail

INNER JOIN invoiceheader ON invoicedetail.headerid = invoiceheader.idheader

GROUP BY invoicedetail.headerid