Page 1 of 1
disable the choice in drop down
Posted: 18 Apr 2017
by May.AlFarsi
if I have multiple values of choices and I want to disable some of them based on user log in how can I do that ??
Re: disable the choice in drop down
Posted: 18 Apr 2017
by Dmitry Kozlov
Hi May,
Here is the code you can use to hide the second option in the drop-down:
Code: Select all
fd.field('DropDown').control()._el().find('select option:eq(1)').hide()
Replace 'DropDown' with the internal name of your field.
And the following line hides the 'Enter Choice #3' option:
Code: Select all
fd.field('DropDown').control()._el().find('select option[value="Enter Choice #3"]').hide()
Re: disable the choice in drop down
Posted: 19 Apr 2017
by May.AlFarsi
should it check what is the value of the choice ?? how did you define the choice value
Re: disable the choice in drop down
Posted: 20 Apr 2017
by Dmitry Kozlov
Not sure that I understood your case - could you describe it in more detail?
The code above hides an option by its index or by a display value. I expected that you know what options you have in the drop-down otherwise how do you want to hide them?
Re: disable the choice in drop down
Posted: 23 Jun 2017
by Katy
Hello, I am trying to use the second option with check-box choice and it doesn't work. Could you please check it? I tried to change the field to radio buttons - the same result... I also tried to insert .find('Enter Choice #3') - no luck..
Re: disable the choice in drop down
Posted: 26 Jun 2017
by Dmitry Kozlov
Hi Katy,
Here is the code for getting selected options from a multi-choice field:
Code: Select all
var checkboxIndex = 2;
fd.field('MultiChoice').control()._el()
.find('input[type="checkbox"]').eq(checkboxIndex)
.is(':checked');
https://spform.com/javascript-framework ... eld-values
Re: disable the choice in drop down
Posted: 26 Jun 2017
by Katy
I'm sorry, i think i am missing something... So let's say i have a Colour choice column with check-boxes display and following choices:
Red
Green
Black
Yellow
And i need to hide Red and Black based on the condition X. I thought it would look like this:
function setColour() {
if (fd.field('Condition').value() == 'X') {
fd.field('Colour').control()._el().find('select option[value="Red"]').hide();
fd.field('Colour').control()._el().find('select option[value="Black"]').hide();
}
}
fd.field('Condition').change(setColour);
setColour();
Should it look like this?:
function setColour() {
var checkboxIndex1 = 1;
fd.field('Colour').control()._el()
.find('input[type="checkbox"]').eq(checkboxIndex)
.is(':checked');
var checkboxIndex2 = 3;
fd.field('Colour').control()._el()
.find('input[type="checkbox"]').eq(checkboxIndex)
.is(':checked');
if (fd.field('Condition').value() == 'X') {
fd.field('Colour').control()._el().find(checkboxIndex1).hide();
fd.field('Colour').control()._el().find(checkboxIndex2).hide();
}
}
fd.field('Condition').change(setColour);
setColour();
Re: disable the choice in drop down
Posted: 27 Jun 2017
by Dmitry Kozlov
Hi,
Please, use the code below to hide the second option:
Code: Select all
fd.field('FieldName').control()._el().find('tr:eq(1)').hide();
Just replace '1' with 0-based index of the option you want to hide.