I'm trying to add javascript to the dispform.aspx page of my form to hide certain columns/fields based on a dropdown menu. When I add the code to the CEWP it simply adds text above the fields; the javascript/jquery completely doesnt work. Even when I saved the code as a text file and tried using it as a content link it just added text above the form containing the code and now I cant get ride of it. Here's the code:
<script src="/sites/Newsite1/SiteAssets/jquery-1.9.0.min.js" type="text/javascript"></script><script type="text/javascript">
// Execute the following JavaScript after the page has fully loaded, when it's ".ready"
$(document).ready(function() {
//Define which columns to show/hide by default
$('nobr:contains("stuff1")').closest('tr').hide();
$('nobr:contains("stuff2")').closest('tr').hide();
//Show/hide columns based on Drop Down Selection
$("select[title='test']").change(function() {
if ($("select[title='test']").val() == "none") {
$('nobr:contains("stuff1")').closest('tr').hide();
$('nobr:contains("stuff2")').closest('tr').hide();
} else if ($("select[title='test']").val() == "hide") {
$('nobr:contains("stuff1")').closest('tr').show();
$('nobr:contains("stuff2")').closest('tr').hide();
$('nobr:contains("stuff3")').closest('tr').hide();
} else($("select[title='test']").val() == "show") {
$('nobr:contains("stuff1")').closest('tr').show();
$('nobr:contains("stuff2")').closest('tr').show();
$('nobr:contains("stuff2")').closest('tr').show();
}
});
});
</script>