Using the following, I'm making a field visibly only when a certain value is selected from the field preceding it. When I embed this into my page code, the field is initially hidden, but doesn't appear when I select the value intended to trigger it.
When I run this script in the Firebug console, replacing _spBodyOnLoadFunctionNames.push("websiteField"); with simply websiteField(); everything worked perfectly. But it only worked in the console, not after I embedded it.
Is there anything syntax-wise that's "off" about this?
<script type="text/javascript">
function websiteField() {
var packageTypeField = $("#formCss select");
var websiteTR = packageTypeField.closest("tr").next();
websiteTR.hide();
$("packageTypeField").change(function(){
if ($(this).val() == "Comprehensive") {
websiteTR.slideDown();
}
else {
websiteTR.slideUp();
}
});
}
_spBodyOnLoadFunctionNames.push("websiteField");
</script>