⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Calculated Values



dwdc
  • profile picture
  • Member

Posted 28 February 2014 - 07:53 AM

Is there a way to add rows to GC ADD and EDIT forms that are simply calculations of fields in the target table (not actual fields)?

For example: Let's say I have the following real fields in my table:

low_bid
high_bid

winning_bid

I want to have a few values that are simply READ ONLY values that RE-CALC when related field values are modified:

low_bid_50p = (low_bid * .5)
high_bid_50p = (high_bid * .5)
agent_fee = if((winning_bid *.065) < 1750 THEN 1750 ELSE (winning_bid *.065))

I can do this easy enough in RAW PHP/mySQL along with javascript to make sure values re-calculate when user adds/modifies values at the data entry level. Was wondering if anyone has pulled this off in GC.

Any help would be appreciated. Thanks!


 

 


Amit Shah
  • profile picture
  • Member

Posted 28 February 2014 - 08:40 AM

Hi there,

 

very first ... for the required solution here - u can use field_type of the field to set it to be read only...

Post that .. u need to create a javascript that will hook to the fields on the change of which u want to work on update. Then add that js file to the GC output using set_js

 

This 2 simple things can derive u to your solution ..

 

Happy GCing);


Robert
  • profile picture
  • Member

Posted 28 February 2014 - 08:59 AM

I was working on this to .. i will post the code in a few h or tomorrow ...