Hide fields based on choice radio

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
ds4be
Posts: 20
Joined: Fri Nov 07, 2014

28 Jan 2015

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();

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

29 Jan 2015

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();

ds4be
Posts: 20
Joined: Fri Nov 07, 2014

03 Feb 2015

Thanks,

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests