0

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>
4

1 に答える 1

0

私はあなたが意図したと思います:

$("packageTypeField").change(function(){

することが:

$(packageTypeField).change(function(){
于 2013-10-02T19:20:28.387 に答える