Forum


Calc Builder Support

Calc Builder support
Forums
Public write access is disabled. Please login

Hide/Show form sections depending on select radiobutton 25.11.2013 09:55

hello,
during construction calculator I took the "Example calculators: Hide / Show form sections depending on the select combo box (I)". I would like to get the same effect when using radiobutton. Could I have a short code javascript, which acted to on radiobutton? :)

Best Regards,
Marcel Haberski

Re: Hide/Show form sections depending on select radiobutton 25.11.2013 10:12

Hi,
the lines to get this working with radiobuttons are similar, but the selector to find checked option changes a little bit. We suggest to download the second example (using slide effect). It uses a simpler sintax and the only changes you'd need to do to use radiobuttons based on that example:

- Change the field optfield from 'option list' type to 'radiobutton' at fields configuration.

- At the js tab, the code would be:

//we hide all sections
CB(".dinstyle").hide();

//when radiobutton is changed:
CB("input[fldname='optfield']").change(function(){

//hide all sections
CB(".dinstyle").hide();

//get the checked option to build the name of the section to be shown.
CB(".opt-"+CB("input[fldname='optfield']:checked").attr("mv_option")).show(500);

});


Please contact again if you need more help with any of the steps.


Regards
Moonsoft Team
www.moonsoft.es

Re: Hide/Show form sections depending on select radiobutton 25.11.2013 10:56

thanks for the quick reply :)

script works, but still I would like to find out how to get to a particular radiobutton to trigger a specific event (as in the case of option list: "if (elemSelected == 'opt4') {...}")
the name of my field of radiobutton is "second_tab" and radiobuttonns turn: val1, val2, val3

regards :)

Edited by moon_1338 - 25.11.2013 10:57

Re: Hide/Show form sections depending on select radiobutton 25.11.2013 12:55

Hi,
the value returned is at this part:

CB("input[fldname='optfield']:checked").attr("mv_option")

So, you can recover which option is selected:

var selected=CB("input[fldname='optfield']:checked").attr("mv_option");

and then apply the conditions needed:

if(selected=="val1"){

.....
}


Hope this helps, regards
Moonsoft Team
www.moonsoft.es

Re: Hide/Show form sections depending on select radiobutton 25.11.2013 16:25

work!, thank you! :)
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect

Our clients' feedback