• 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: Solved: Clear conditional fields on new selection

Solved: Clear conditional fields on new selection 10 years 5 months ago #29628

I've found several forum posts and articles in the documentation about clearing conditional fields when a new selection in made in a certain field, but none of the solutions seem to work in my situation. I'm using the new payment plugin fields.

The form: vektive.us/test3/index.php?option=com_rsform&formId=7
User selection from "Number of days" that a tournament will be entered shows:
  • A dropdown with single days listed for a one day entry, or
  • A dropdown with two day combinations for 2 day entry

Users can also purchase a Bonus Card for $5/per day for each day they are entering. These are configured into three separate fields ($5, $10, $15) where the corresponding Bonus Card amount displays depending on the number of days they select to enter - for example a 2 day entry shows the $10 Bonus Card product field.

The issue is that if the user makes a 'Number of Days' selection and chooses options in the corresponding 'Days Entering' and 'Bonus Card' fields, these selections remain if the user makes a new choice from the 'Number of Days' field which affects the correct price total. The form needs to reset the 'Which Days' fields and 'Bonus Card' fields if a new selection is made from the 'Number of Days' field.
Last Edit: 10 years 5 months ago by paulnoyola.
The administrator has disabled public write access.

Clear conditional fields on new selection 10 years 5 months ago #29657

I think I have a solution. One of the issues that I was having was that when using the new Payment fields, they assign their own element ID instead of using the field name like I believe the non-payment fields do. Using Firebug, I was able to identify the field IDs and plug them into code I found on the forum post - www.rsjoomla.com/forum/37-rsform-pro/238...eld-clear-field.html

Keep in mind, I am a beginner Javascript'er so some of the following is most likely not as tidy as it should be, but it seems to function as I needed. Hope it gets you started on coding your form. If you have suggestions on my Javascript, please let me know!

The form with the following code is here: vektive.us/test3/index.php?option=com_rsform&formId=8
(I removed the conditional field functions so you can see the script clear the input of the fields)

In the JS scetion on the properties tab on the form editor, I used this:
<script type="text/javascript">
function clearDays(){
var first = document.getElementById('payment-81-0'); 
var second = document.getElementById('which1day'); 
var third = document.getElementById('which2day'); 
var fourth = document.getElementById('payment-84-0'); 
var fifth = document.getElementById('payment-85-0'); 
var sixth = document.getElementById('payment-86-0'); 
if (first.value != "0") {
second.value = " ";
third.value = " ";
fourth.value = document.getElementById('payment-84-0').checked=false;
fifth.value = document.getElementById('payment-85-0').checked=false;
sixth.value = document.getElementById('payment-86-0').checked=false;
}	
}
</script>

and on the first payment field where you select the number of tournament days you are entering (field ID payment-81-0), I used the following in the additional attributes field to trigger the script:
onchange="clearDays();"
Last Edit: 10 years 5 months ago by paulnoyola.
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!