Conditional fields in sharepoint

SP Engage 1 Reputation point
2021-07-15T20:52:34.537+00:00

Used this script from another user to conditionally hide a field. How do I expand this to be able to do more than one field. I want to be able to build long form with lots of choices based on conditions. If easier way but this was easiest I could find. Apologize. Newbie to coding

<script src="//code.jquery.com/jquery-3.1.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var selectFieldName="other items"; // dropdown field display name
var otherFieldName="other";// single line of text field display name
$("input[title='"+otherFieldName+"']").closest("tr").hide();
$("select[title='"+selectFieldName+"']").change(function(){
if($(this).val()=="Other"){
$("input[title='"+otherFieldName+"']").closest("tr").show();
}else{
$("input[title='"+otherFieldName+"']").closest("tr").hide();
}
});
});
</script>

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,197 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CaseyYang-MSFT 10,436 Reputation points
    2021-07-16T09:27:27.027+00:00

    Hi @SP Engage ,

    Could you explain what do you mean "long form with lots of choices"? If you want to use column type Choice with multiple selections, I'm sorry SharePoint conditional formulas do not currently support this column type.

    For Reference:
    https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/list-form-conditional-show-hide#specify-conditional-formula-to-show-or-hide-columns


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.