This topic is locked

Adding prices

12/22/2015 1:20:53 PM
PHPRunner General questions
L
lcslouis author

I have a project where someone selects an event it has a price and then someone selects some sub-events each sub event has a price.
The Event listing is using the Lookup wizard and is connected to a database table.
The Sub-Event listing is also using the Lookup wizard and is also on the database table.
I also have a field called NumberOfCrew that defaults to 3. If 3 or less it the additional price is 0 for each one over 3 it is $45.00
I need to add everything together.
The field total due is where the value would be saved.
Here is a link on the demo account. I have only have on this page what is needed to be figured out.
http://demo.asprunner.net/lcslouis_gmail_com/AddTest/dbo_EventSignUp_add.php
here is a link to the project file
https://www.dropbox.com/s/d78uu4pjfz9j46j/AddTest.phpr?dl=0

L
lcslouis author 12/29/2015

Is This that big of a problem that no one knows how to do it.

Sergey Kornilov admin 12/29/2015

This most likely means forum is not the right place for questions like this. If you have a valid support contract contact support directly.
If you want to get help here you need to elaborate your question so it can be understood. It is not clear if you already wrote some piece of code and it didn't work or you need some general guidance or you need someone to write this code for you.
I have checked your sample page and it doesn't even have a price field so it is not clear what and how you want to add together.

L
lcslouis author 12/29/2015

The price field or prices fields are apart of the dropdown list for the dropdown and each price is showed as apart of each checkbox item.
There are 2 prices fields in it.
memberPrice and nonMemberPrice
there is no price field on the page there is only a total.
I have tried doing it is sql code only but that doesn't work.
I need to make it work on the page in javascript and have no idea how to do it.

L
lcslouis author 12/31/2015

Here is a clarification to what I am wanting to do.
As stated I need to add prices together here is how the data is now.
The page event signup has 2 lookup wizards that lookup to 2 different tables events and sub-events
This page is on the table eventsignup
The events table stores the name of the event and the price of the event as well as extra crew fee.
Field names are as follow. EventName, memberprice1, extracrewfee
The sub-events table has subevent name, memberprice1,

this is a checkbox multi-select list.
I need to add the prices together on the fly and put the total due in the total filed on event signup page.
so it would be event member price

and then each subevent memberprice added and totaled
The total is then add with the on the extra crew calculation.
Also the field number of crew is extra crew defaults at 3 but can be changed by the user the price is from the event.extracrewfee so [3 X events.extracrewfee]
SO the formula is [events.memberprice1]+[subevents.memberprice1]+[eventsignup.numberofcrew X events.extracrewfeee] = [eventsignup.totaldue]
Of course the formula may change depending on how many subevents are selected and it can be no sub events selected.

Sergey Kornilov admin 12/31/2015

Still doesn't make any sense, at least to me.
It is not clear if you already wrote some piece of code and it didn't work or you need some general guidance or you need someone to write this code for you.
I have checked your sample page and it doesn't even have a price field so it is not clear what and how you want to add together. You cannot add something that is not on the page.

L
lcslouis author 12/31/2015

I have no code made.
I tried to do this is in SQL on a view but the sql doesn't work.
This page will not have a price field.
As I said in other reply
The prices are apart of the the tables being used in the lookup wizards.
The field name of the prices is called memberprice1.
Here is the sql that I tired first as a custom view on the view page of this page.



with tmp(SingleIDNum, SubEventsIDNums) as (

select LEFT(SubEventsIDNums, CHARINDEX(',',SubEventsIDNums+',')-1),

STUFF(SubEventsIDNums, 1, CHARINDEX(',',SubEventsIDNums+','), '')

from [HSR].[dbo].[EventSignUp]

WHERE IDNum = 6

union all

select LEFT(SubEventsIDNums, CHARINDEX(',',SubEventsIDNums+',')-1),

STUFF(SubEventsIDNums, 1, CHARINDEX(',',SubEventsIDNums+','), '')

from tmp

where SubEventsIDNums > ''

)

select SUM(CAST(SubEvents.MemberPrice1 AS money)) as [Total Due]

from tmp, [HSR].[dbo].[SubEvents]

where SubEvents.IDNum = CAST(SingleIDNum AS INT)


The non on the fly method is by using sql code to do the work.
But this sql code has to be executed before the view page is displayed.
And the IDNum is the record number of event signup I would need to get it from the record they are loading and pass it to this sql.
How do you make that work.

Sergey Kornilov admin 12/31/2015

If you need to perform some price calculation on the page you need to have those price fields right on the page. Then you can use Javascript calculation as described in method #3 at http://xlinesoft.com/articles/how_to_use_calculated_fields.htm

L
lcslouis author 12/31/2015

Alright this is a problem that is not supported by phprunner.
Very Stupid.
Topic Closed.