I have a SharePoint list with the following single line of text fields:
Title
, Year
and Type or Location
. I want to be able to hide the Type or Location
table row in the default display form. I know that I should create a JavaScript script and put it in Content Editor web part inside DispForm.aspx.
I am not fluent with jQuery syntax, thus I need help with the code, i.e. I don't know how to reference the table row which contains
Type or Location
field and its value. Here's what I've done so far, but it doesn't work:
I know that the
'input[title='Type or Location']'
part is incorrect; at least I think it's that. Could anyone help me out? Thank you.
Boris
BorisBoris
4,99629 gold badges91 silver badges138 bronze badges
6 Answers
Rich BennemaRich Bennema
9,4804 gold badges32 silver badges53 bronze badges
I am not sure why you want to use jQuery for that. In SharePoint, you can choose to make a field required, optional or hidden. In most cases, just switching to hidden will address your issue.
For the record, I would also try to avoid as much as possible the use of jQuery(document).ready, it might conflict with the SharePoint out of the box onload event. In your case it is not needed.
Update: here is a way to do this with jQuery:
Christophe
16.1k19 gold badges76 silver badges122 bronze badges
Chris GesslerChris Gessler
18.6k3 gold badges39 silver badges73 bronze badges
It depends what type of column Type ior Location is. If it's a Single line of text, then you're close. You should use a DOM inspector like IE's Developer Tools or Firebug to see what the actual title of the input element is.
If the column is a different type, then it's likely not an input element. Using the DOM inspector again, you can look at what elements make up the field control and decide on your selector from that.
Finally, remember that hiding things in script is not secure. A savvy user can turn off the script or otherwise change the script so that they can edit it. It all depends on your requirements.
// UPDATE //Ah, you said DispForm. As was pointed out in another answer, there aren't any input elements in a DispForm. You need to correct your selector.
Marc D AndersonMarc D Anderson
If its just the Default Display Form, How about just creating a view and making it default?
AR Ebhendra PagotiAR Ebhendra Pagoti
Drew Gaynor
6,5455 gold badges33 silver badges47 bronze badges
KishanKishan
Not the answer you're looking for? Browse other questions tagged javascriptjquerysharepoint or ask your own question.
For one of the lists, I have to hide column Project (single line of text) based on the choice column 'Customer' drop down selection. I have two values in customer drop down: Customer W Project and Customer WO Project. If the user selects
Customer W Project
, I want to hide Project column field on the new item click form. Below is the code I am using, please let me know if anything is wrong:Also, I am working on SharePoint 2016 online/office 365.
Any help will be greatly appreciated. Thanks.
K.Dᴀᴠɪs
7,77511 gold badges25 silver badges40 bronze badges
mdevmmdevm
1 Answer
Your jQuery library is so old.Below code works based on my testing.
Lee_MSFTLee_MSFT
2,2121 gold badge2 silver badges7 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Not the answer you're looking for? Browse other questions tagged sharepointoffice365 or ask your own question.
Duck tales season 2 2017 torrent free. Some images used on this website are taken from the web and believed to be in the public domain. This website does not knowingly intend or attempt to offend or violate any copyright or intellectual property rights of any entity.
I am not fluent with jQuery syntax, thus I need help with the code, i.e. I don't know how to reference the table row which contains
Type or Location
field and its value. Here's what I've done so far, but it doesn't work:
I know that the
'input[title='Type or Location']'
part is incorrect; at least I think it's that. Could anyone help me out? Thank you.
Boris
BorisBoris
4,99629 gold badges91 silver badges138 bronze badges
6 Answers
Rich BennemaSharepoint Hide Fields In Form
Rich Bennema
9,4804 gold badges32 silver badges53 bronze badges
I am not sure why you want to use jQuery for that. In SharePoint, you can choose to make a field required, optional or hidden. In most cases, just switching to hidden will address your issue.
For the record, I would also try to avoid as much as possible the use of jQuery(document).ready, it might conflict with the SharePoint out of the box onload event. In your case it is not needed.
Update: here is a way to do this with jQuery:
ChristopheChristophe
16.1k19 gold badges76 silver badges122 bronze badges
Chris GesslerChris Gessler
18.6k3 gold badges39 silver badges73 bronze badges
It depends what type of column Type ior Location is. If it's a Single line of text, then you're close. You should use a DOM inspector like IE's Developer Tools or Firebug to see what the actual title of the input element is.
Sharepoint Online Hide A Field Video
If the column is a different type, then it's likely not an input element. Using the DOM inspector again, you can look at what elements make up the field control and decide on your selector from that.
Finally, remember that hiding things in script is not secure. A savvy user can turn off the script or otherwise change the script so that they can edit it. It all depends on your requirements.
// UPDATE //Ah, you said DispForm. As was pointed out in another answer, there aren't any input elements in a DispForm. You need to correct your selector.
Marc D AndersonMarc D Anderson
If its just the Default Display Form, How about just creating a view and making it default?
AR Ebhendra PagotiAR Ebhendra Pagoti
Drew Gaynor
6,5455 gold badges33 silver badges47 bronze badges
KishanKishan