Hide fields based on choice radio
Hi
I am trying to hide some fields based on a choice field - Radio buttons, i used the following code, which works OK on Choice - Dropdown but not on radio?
/ Enable or disable 'Complaint Fields'
function setComplaintTable() {
var p = fd.field('Warranty_x0020_or_x0020_Complain').control().value();
if (p == 'Complaint') {
$('.ext-field').hide(); // Enable
$('.complaint-hide').hide(); // Disable
}
else {
$('.ext-field').show(); // Disable
$('.complaint-hide').show(); // Enable
}
}
// Subscribe on status change
fd.field('Warranty_x0020_or_x0020_Complain').control().change(function () {
setComplaintTable();
});
// Initialize
setComplaintTable();
I am trying to hide some fields based on a choice field - Radio buttons, i used the following code, which works OK on Choice - Dropdown but not on radio?
/ Enable or disable 'Complaint Fields'
function setComplaintTable() {
var p = fd.field('Warranty_x0020_or_x0020_Complain').control().value();
if (p == 'Complaint') {
$('.ext-field').hide(); // Enable
$('.complaint-hide').hide(); // Disable
}
else {
$('.ext-field').show(); // Disable
$('.complaint-hide').show(); // Enable
}
}
// Subscribe on status change
fd.field('Warranty_x0020_or_x0020_Complain').control().change(function () {
setComplaintTable();
});
// Initialize
setComplaintTable();
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
You should compare the selected option by its index instead of the display text:
Code: Select all
// Enable or disable 'Complaint Fields'
function setComplaintTable() {
var p = fd.field('Warranty_x0020_or_x0020_Complain').control().value();
if (p == 1) {
$('.ext-field').hide(); // Enable
$('.complaint-hide').hide(); // Disable
}
else {
$('.ext-field').show(); // Disable
$('.complaint-hide').show(); // Enable
}
}
// Subscribe on status change
fd.field('Warranty_x0020_or_x0020_Complain').control().change(function () {
setComplaintTable();
});
// Initialize
setComplaintTable();
-
- Information
-
Who is online
Users browsing this forum: No registered users and 9 guests