• 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: Using Conditions with a text box or calendar field

Using Conditions with a text box or calendar field 7 months 3 weeks ago #43626

  • stories
  • stories's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 1
It took me a minute to figure this out, so I thought I would share it with people. This is how to get conditions to work when you need to apply them to values taken from calendar fields or text boxes.
  1. Create the text box or calendar field that will trigger the conditions
  2. Create Yes/No radio buttons and set their container as display none with CSS in the CSS section of Form Properties.
  3. Create fields you want to show/hide based on the value of the radio buttons
  4. Create the appropriate conditions for the radio button
  5. In form preprocessing PHP script set the default value of the radio button based on whether you want the fields attached to the condition to show or hide on load of the form. This could be based on a value coming from a data table or the fact the field that is triggering the conditions through the radio buttons is empty.
  6. If using a text box to trigger conditions:
    1. In Javascript, create a function that accepts the id of the text field so that you can get the value.
    2. If the value of the text field warrants a change in the value of the radio button, set the new value of the radio button.
    3. After you have assigned the value of the radio button add the corresponding javascript function for the condition for that value of the radio button, which is rsfp_runConditions with the condition's item id attached to it (rsfp_runConditions1, for instance). You can find this in the database table for conditions or you can look in the head section of the webpage on the form to find the function, which will be in one of the <script> tags.
    4. Do the same for the other value of the radio button.
    5. Either add the attribute onchange="nameofFunctionthatTriggersCondition(id of text field)" or add the event listener via javascript or if dynamically creating a value for the text field, then run the function inside the function that sets the text field's value.
  7. If using a calendar field to trigger conditions:
    1. RSForms has a convenient function name that is triggered when the value of the calendar field changes (rsfp_onSelectDate), which you will need to use. It is described here. The action of this function can be anything as you define it, but you must have at least one variable passed to it, and that is the value of the calendar field. Within this function, based on the date passed to it, you can set the radio button value and call the appropriate rsfp_runConditions function that will trigger the condition you want.
    2. You do not need to add anything to the calendar field itself to trigger the calendar function. It is automatically triggered when a date is set,

Hope this helps someone!
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!