• 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: Show hide based on hidden field numeric value

Show hide based on hidden field numeric value 11 months 2 days ago #42818

  • bob3
  • bob3's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
I have a form with two donation payment fields. One is prepopulated with 80.00.

There is a hidden "Totals" field that adds these two fields.

Then there is a Free Text field titled "HideSend". This field obscures the send button.

What I want to happen on display is if the "Totals" field is 79.99 or less the "HedeSend" field appears.

End result is that both fields need to add up to at least 80.00

I need a JavaScript that will evaluate on field change. Any ideas?
Robert Clinton
Owner

CAPE COD WEB DEVELOPERS
Harwich, Ma
Last Edit: 11 months 2 days ago by bob3.
The administrator has disabled public write access.

Show hide based on hidden field numeric value 10 months 3 weeks ago #42828

  • iceferret
  • iceferret's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 216
  • Thank you received: 57
I have something similar which changes styles and enables or disables various options in a dropdown field which is called using window.onload so is similar to what you are asking for. Try this which is called the same way so should evaluate the initial state of the fields and update hidesend when the input fields change. You'll need to change 'field1' and 'field2' to the actual names of your fields in the getElementById calls.
// Function to evaluate the fields and toggle visibility of "HideSend" field
function evaluateFields() {
  var field1 = parseFloat(document.getElementById("field1").value); // First donation payment field
  var field2 = parseFloat(document.getElementById("field2").value); // Second donation payment field
  var totals = field1 + field2; // Total sum of the two fields
  var hideSendField = document.getElementById("HideSend"); // HideSend field
 
  if (totals <= 79.99) {
    hideSendField.style.display = "block"; // Show the HideSend field
  } else {
    hideSendField.style.display = "none"; // Hide the HideSend field
  }
}
 
// Event listener for field changes
document.getElementById("field1").addEventListener("input", evaluateFields);
document.getElementById("field2").addEventListener("input", evaluateFields);
 
// Call the evaluateFields function when the window loads
window.onload = function() {
  evaluateFields();
};
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: bob3

Show hide based on hidden field numeric value 10 months 3 weeks ago #42829

  • bob3
  • bob3's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
Thanks iceferret -

I'll give it a try and let you know how I do!
Robert Clinton
Owner

CAPE COD WEB DEVELOPERS
Harwich, Ma
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!