Disable Next depending on a variable

By: David Costin | Asked: 05/12/2023
ForumsCategory: General questionsDisable Next depending on a variable
David Costin asked 2 years ago
Note: I am an absolute begginer! I have the following script that works fine (it has been adapted from a script that made reference to a Radio Field): - jQuery(document).ready(function($){
var fieldID = 12156;
var showVal = '19489'
var $nextButton = $(".frm_button_submit"); if (($("input[name^='item_meta[" + fieldID + "]']").val() != showVal) && ($("input[type=hidden][name^='item_meta[" + fieldID + "]']").val() != showVal)) {
$nextButton.css('visibility','visible');
} $("input[name^='item_meta[" + fieldID + "]']").change(function(){
if ($("input[name^='item_meta[" + fieldID + "]']").val() == showVal){
$nextButton.css('visibility','hidden');
} else {
$nextButton.css('visibility','visible');
}
});
}); What I want to do is disable the Next button by making reference to a field that has variable data.  In my naivety I assumed that - var showVal could access the field by inserting the field ID. 
1 Answers
Victor Font answered 2 years ago
You said the script works fine. It's overly complicated for what you want to do but throughout the code, you're comparing the value ( val() ) of a field against a field id 19489. You have to compare val() against the value of the radio button, not the field ID.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right