• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: How do I place a calculated field on my form?

How do I place a calculated field on my form? 15 years 7 months ago #5132

How do i place a calculated field on my form...

Example...

In a drop down box is listed 4 items A to D

Item A is valued at $10
Item B is valued at $14
Item C is valued at $18
Item D is valued at $20

The user chooses item A

I then want the value to appear in a text box (or input box that is uneditable)

Is this possible?
The administrator has disabled public write access.

Re:How do I place a calculated field on my form? 15 years 6 months ago #5172

  • octavian
  • octavian's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 783
  • Thank you received: 110
Hello,
I've setup 2 components:
- a dropdown
Name: Items
Items: Item A
Item B
Item C
Item D
Additional Attributes: onchange=\"calculate_price(this)\"
- a textbox
Name: Price
Additional Attributes: readonly=\"readonly\"

In the Form Layout tab, disable the Auto Generate Layout feature, this will allow you to paste code into the HTML layout. At the bottom of the layout, paste this code:
<script type="text/javascript">
var prices = new Array();
prices['Item A'] = '50$';
prices['Item B'] = '150$';
prices['Item C'] = '250$';
prices['Item D'] = '350$';
 
function calculate_price(what)
{
 document.getElementById('Price').value = prices[what.value];
}
</script>
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!