Let's assume I have a “products” channel which contains 3 fields: price(number), discount(integer 1 to 100), discounted_price(number).
Is there a way to populate the discounted_price field in CP, based on price - (price * discount / 100)?
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It only takes a minute to sign up.
Sign up to join this communityYou'll want to handle this using jQuery/JavaScript in your field's instructions.
You can include HTML in the Instructions field for your custom field. So you can include:
<script type="text/javascript">
// Do some stuff
</script>
You can set your code to fire onblur on your fields, so that every time a field is updated, the JS runs, and calculates the value for the other field.
You can do a View Source on the entry screen to find all the field references you need for your jQuery code.