Page 1 of 1

Need help to hide a tab

Posted: 04 Feb 2015
by oren944
Hello,


I am trying to disable a tab until the user has chose a certain option in a drop down menu. how would i go about programming this?


This is what i have so far however it is not working...

function setPhoneTab()
{
var status = fd.field('Choose_x0020_contact_x0020_optio').control().value();
if (status == 'Letter')
{
$('#fd_tabcontrol-o').tabs('option', 'disabled', null);
}

else
{
$('#fd_tabcontrol-o').tabs('option', 'disabled', [1]);
}
}

var status = fd.field('Choose_x0020_contact_x0020_optio').control().chnage(function()
{
setPhoneTab();
});

setPhoneTab();

Re: Need help to hide a tab

Posted: 05 Feb 2015
by Dmitry Kozlov
Please, try the following code:

Code: Select all

function setPhoneTab() 
{
	var status = fd.field('Choose_x0020_contact_x0020_optio').value();
	if (status == 'Letter')
	{
		
		$('#fd_tabcontrol-0').tabs('option', 'disabled', null);
	}
	else
	{
		$('#fd_tabcontrol-0')
			.tabs('option', 'active', 0)
			.tabs('option', 'disabled', [1]);
	}
}

fd.field('Choose_x0020_contact_x0020_optio').change(function()
{
	setPhoneTab();
});

setPhoneTab();

Re: Need help to hide a tab

Posted: 05 Feb 2015
by oren944
Thank you ! This worked.

Re: Need help to hide a tab

Posted: 05 Feb 2015
by oren944
How would I go about doing more than one tab like that? for example i have multiple tabs aa drop down menu. once the user selects a option then that tab is now availble to be clicked on.

Re: Need help to hide a tab

Posted: 06 Feb 2015
by Dmitry Kozlov
Hi,

Just add conditions for other options to the code:

Code: Select all

function setPhoneTab() 
{
	var status = fd.field('Choose_x0020_contact_x0020_optio').value();
	switch (status) {
		case 'Option 1':
			$('#fd_tabcontrol-0')
				.tabs('option', 'active', 0)
				.tabs('option', 'disabled', [2]);
			break;
			
		case 'Option 2': 
			$('#fd_tabcontrol-0')
				.tabs('option', 'active', 0)
				.tabs('option', 'disabled', [1]);
			break;
		default:
			$('#fd_tabcontrol-0')
				.tabs('option', 'active', 0)
				.tabs('option', 'disabled', [1, 2]);
			break;
	}
}

fd.field('Choose_x0020_contact_x0020_optio').change(function()
{
	setPhoneTab();
});

setPhoneTab();