Page 1 of 1

Hide fields based on choice radio

Posted: 28 Jan 2015
by ds4be
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();

Re: Hide fields based on choice radio

Posted: 29 Jan 2015
by Dmitry Kozlov
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();

Re: Hide fields based on choice radio

Posted: 03 Feb 2015
by ds4be
Thanks,