Hide fields based on choice radio

rss

Posted by ds4be - Jan 28 ’15 at 11:35

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

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 8 years 7 months 25 days
    #1 by Dmitry Kozlov Jan 29 ’15 at 10:24

    You should compare the selected option by its index instead of the display text:

    // 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
    Member
    Member for: 7 years 6 months 8 days
    #2 by ds4be Feb 3 ’15 at 10:32

    Thanks,

Displaying 1 to 2 of 2 messages