Hi,
I am looking for a JavaScript that hides person or group field based on choice field. for example i have one choice field called "Company" and have values in it like Google , Microsoft and Amazon. And I also have another three person or group fields called Google Team, Microsoft Team and Amazon Team. depends on the choice value the respective team field should show up and remaining fields should be hidden. I am using the below query but it's not working as expected.
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <script type="text/javascript">
$(document).ready(function(){
//Define which columns to hide by default
$(‘nobr:contains(“Google Team”)’).closest(‘tr’).hide();
$(‘nobr:contains(“Microsoft Team”)’).closest(‘tr’).hide();
$(‘nobr:contains(“Amazon Team”)’).closest(‘tr’).hide();
//Show/hide columns based on Drop Down Selection
$(“select[title=’Company’]”).change(function() {
if ($(“select[title=’Company’]”).val() == “1”) {
$(‘nobr:contains(“Google Team”)’).closest(‘tr’).show();
$(‘nobr:contains(“Microsoft Team”)’).closest(‘tr’).hide();
$(‘nobr:contains(“Amazon Team”)’).closest(‘tr’).hide();
} else if($(“select[title=’Company’]”).val() == “2”){
$(‘nobr:contains(“Microsoft Team”)’).closest(‘tr’).show();
$(‘nobr:contains(“Google Team”)’).closest(‘tr’).hide();
$(‘nobr:contains(“Amazon Team”)’).closest(‘tr’).hide();
} else if($(“select[title=’Company’]”).val() == “3”){
$(‘nobr:contains(“Amazon Team”)’).closest(‘tr’).show();
$(‘nobr:contains(“Google Team”)’).closest(‘tr’).hide();
$(‘nobr:contains(“Microsoft Team”)’).closest(‘tr’).hide();
}
});
});
</script>Any Idea why it's not working ?