Forums

What to hide a field in my form until a selection is made in radio box (Yes/No)

myfairlaydee123 27 Mar, 2018
My work's website has a registration form that in one of the questions, ideally, if you click 'Yes' a hidden field suddenly appears and if you click 'No' it disappears.
At the moment, the field is there by default and only disappears AFTER you click 'No' and of course reappears if you click 'Yes'.
What I need is for the field to be HIDDEN ON DEFAULT, with the option of it appearing by clicking 'Yes' or disappearing again by clicking 'No'.
The Yes/No option is a radiobox and the hidden field is actually a container fyi.
I know absolutely nothing about coding or chronoforms and have been thrown in the deep end over the last two days trying to navigate my way around Joomla Form Wizard.
If anybody could please shed some light on what I can change in the code it would be great. The code is currently being used is below and it is used in Events-On Load-Load JS:

!function($) {
$(document).ready(function() {

$('input[name="[mark]secondApplicant[/mark]"]').click(function(){
if($(this).val() == 'Yes'){
$('.applicant2').show();
}else{
$('.applicant2').hide();
}
});

});
}(window.jQuery);

"secondApplicant" represents the radiobox ID and "applicant2" represents the ID of the field I wish to hide. Thank You.
GreyHead 27 Mar, 2018
Hi myfairlaydee123,

Which version of ChronoForms are you using?

NB ChronoForms is not the same as the Joomla! Form Wizard.

Bob
myfairlaydee123 27 Mar, 2018
This just shows how much I don’t know about this kind of thing lol
So, I’m using Joomla Form Wizard to create this registration form on my work’s website. In Joomla Form Wizard, the above code is found under Events-On Load-Load JS to help hide a field when the radio box is ticked No, and to reappear when its ticked Yes. At the moment, this code makes the field visible by default until No is checked on the form.
What I would like to know is if someone would be able to help tweak the code so that the field is hidden on default UNTIL the radiobox is ticked Yes.
I cannot read or write codes at all so I have no idea how it works. I am 100% winging it.
GreyHead 28 Mar, 2018
Hi myfairlaydee123,,

This is the form for the ChronoForms form extension for Joomla! We don't offer support for the Joomla! Form Wizard, sorry.

Bob
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger