Home › Forums › Quform WordPress › Conditional logic – only show submit button when ANY option selected from radio
- This topic has 2 replies, 2 voices, and was last updated 8 years, 5 months ago by
kendavies.
- AuthorPosts
- November 8, 2016 at 2:19 pm #20268
kendavies
ParticipantHi,
First off, great plugin.I need to ask for advice Is there is a way to use conditional logic to display the submit button when ANY option selected from radio button in a group? As the radio button options will be conditional on the first 2 options they could end up being numerous.
So an example function would be:
> Sector: Education
> Role: Director
> Radio list: [ANY]
= display “submit” buttonHere is a link to the current dev. http://bit.ly/2fz98vf
Currently I am using the code which allows the submit on selection of a particular option value. Found at https://support.themecatcher.net/quform-wordpress/guides/advanced/submit-button-conditional-logic
<script>
jQuery(document).ready(function ($) {
var $choices = $(‘.iphorm_1_1’);function checkConditions()
{
if ($choices.filter(‘:checked’).val() == ‘Yes’) {
$(‘.iphorm-submit-wrap-1’).show();
} else {
$(‘.iphorm-submit-wrap-1’).hide();
}
}$choices.click(checkConditions);
checkConditions();
});
</script>Thanks and I look forward to any suggestions
November 9, 2016 at 10:26 pm #20277support
ModeratorHi,
I suggest you ocount the number of radio buttons checked to show the submit button. You could use something like this (notice that I’m using multiple selector) :
<script>
jQuery(document).ready(function ($) {
var $choices = $('.iphorm_1_1, .iphorm_1_8, iphorm_1_12');function radioClicked()
{
if ($choices.filter(':checked').length > 0) {
$('.iphorm-submit-wrap-1').show();
} else {
$('.iphorm-submit-wrap-1').hide();
}
}$choices.click(radioClicked);
radioClicked();
});
</script>Hope this helps,
Regards,Félix
November 15, 2016 at 1:51 pm #20310kendavies
ParticipantThat worked perfectly, exactly what I needed. Thanks Félix.
- AuthorPosts
- You must be logged in to reply to this topic.