• 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: Calculate when exit field

Calculate when exit field 2 years 2 months ago #42535

  • khnoiel
  • khnoiel's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
I have a form with 3 fields to calculate. The calculation is done when I press a button.

Is there a possibility that it is calculated immediately when the text field is exited using the tab key?
The administrator has disabled public write access.

Calculate when exit field 2 years 2 months ago #42547

  • iceferret
  • iceferret's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 246
  • Thank you received: 64
Try this, create four fields 'fieldA. fieldB etc then in the css/javascript section add the following
<script type = "text/javascript">
 
function calc() {
  let a = document.getElementById("fieldA").value||0;
  let b = document.getElementById("fieldB").value||0;
  let c = document.getElementById("fieldC").value||0;  
  let d = 0;
  d =parseInt(a)+parseInt(b)+parseInt(c);
  document.getElementById("text").value = d;
};
 
</script>

and this in the attributes section of fields A-C
onblur="calc();"

fieldD will show the total whichever order the first three fields have a value entered. Note that in the last line getElementById("text") text is the id of fieldD, your field id may be different so if it's not working check that first.
If you can keep your head when all about you are losing theirs, then you obviously don't understand the situation!
The administrator has disabled public write access.
The following user(s) said Thank You: khnoiel
  • 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!