• 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: Dynamic Radio Group change

Dynamic Radio Group change 8 years 2 months ago #36451

  • info6586
  • info6586's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
Hi,
I need to change the items of a radio group based on a selection of a drop down.

Right now I'm using the Conditional Fields feature to show different radio group field and that caused too many confusion and was wondering if i could do that trough JavaScript.

Found the Dynamic Drop-down change here

https://www.rsjoomla.com/support/documentation/rsform-pro/frequently-asked-questions/dynamic-drop-down-change-form-example-.html


how can I change that to show the items for second drop down in radio group insted.

thanks in advance.
The administrator has disabled public write access.

Dynamic Radio Group change 8 years 2 months ago #36471

  • info6586
  • info6586's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
Any idea how to do this?
The administrator has disabled public write access.

Dynamic Radio Group change 8 years 2 months ago #36497

  • Kevin.brackley
  • Kevin.brackley's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 3
Using jquery you can change the content of another form element when another element is changed, such as adding an onblur or onchange/onkeyup, etc. attribute on the primary element, then call a custom js function that modifies the content of the other form field ... $('#element-id').show(); and .hide, etc.

One of the problems we have with doing this is the validation...we have to disable the validation of a field because when the form is submitted, even if the field is hidden, it requires whatever validation rules you have on that field. Where the RSJoomla Conditional route will disregard any validation on fields that aren't displayed. I'm sure this could be reverse-engineered and replicated somehow, we just didn't have the time to do it.

My last form I ended up with two forms. The first form was the primary radio/select fields to being the input, then we did a silent post to a second form to pull in those selections and then conditional fields to hide what we didn't need based on the options selected in the first form.
The administrator has disabled public write access.

Dynamic Radio Group change 8 years 2 months ago #36498

  • info6586
  • info6586's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
Hi Kevin, thanks for the reply.

I've asked a developer for the js code, and he sent me one in jQuery (he said he doesn't know about Joomla and RSform).
<div class="form-group">
   <div class="radio-options"></div>
</div>
$(document).on("change","#select-appliance",function(event)
	{
      var data = optionsItems.data;
 $(".radio-options").html("");
	for(var i in data)
	{
     var item = data[i][this.value];
      for(var j in item)
	{
      $(".radio-options").append("<label> <input type='radio' value='"+item[j].value+"' name='options'>"+item[j].name+"</label><br>");
     // console.log(item[j].value+" ==Daiva== "+ this.value);
    }
	}
    });

The problem I have is that he used a div for radio group and I'm not sure how to add that to the Form.

here is a screenshot of the current Radio group I use in the form. I've used conditional fields, so each time an appliance is selected, it shows the type radio group. We use this for calculating a quote, so it has to be required.

https://drive.google.com/open?id=0B9cDht7ZCF2HYmt1MHVkWEkybVk


Any help would appreciated.
thanks
The administrator has disabled public write access.

Dynamic Radio Group change 8 years 2 months ago #36499

  • Kevin.brackley
  • Kevin.brackley's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 3
There are two ways to address that...one, don't use a javascript #element.onchage() and instead, in the atrributes/additional attributes box of the source field use the onchange="my_function();" (or onblur, etc.).

You can also use this box to add the id="select-appliance" ... but check your jquery element selector to make sure it is triggered on the right element.

Also, you can't use $(document) in Joomla...you need to replace the $ with jquery...so

jquery(document).on(....)

EDIT: replace all $ with jQuery
Last Edit: 8 years 2 months ago by Kevin.brackley. Reason: forgot to mention the $ for all statements
The administrator has disabled public write access.
The following user(s) said Thank You: info6586
  • 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!