Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 同一属性值的Yi2 activeform onchange标签名称_Javascript_Php_Yii2 - Fatal编程技术网

Javascript 同一属性值的Yi2 activeform onchange标签名称

Javascript 同一属性值的Yi2 activeform onchange标签名称,javascript,php,yii2,Javascript,Php,Yii2,在我的下拉列表中,当我选择百分比时,'vendorcommision'(下一个字段)的标签应该是百分比。当我选择Amount时,标签应该是“Amount” 我会这样做: 关闭“vendorcommision”的标签[->label(false)] 使用span作为自定义标签,例如 将事件侦听器添加到下拉列表以更改标签。其内容将包括: var onChangeFunc = function(event) { if($(fixedOrPercentagevendorSelector).val

在我的下拉列表中,当我选择百分比时,
'vendorcommision'
(下一个字段)的标签应该是百分比。当我选择
Amount
时,标签应该是
“Amount”


我会这样做:

  • 关闭“vendorcommision”的标签[
    ->label(false)
    ]
  • 使用span作为自定义标签,例如
  • 将事件侦听器添加到下拉列表以更改标签。其内容将包括:

    var onChangeFunc = function(event) {
        if($(fixedOrPercentagevendorSelector).val() == 1) {
            $('.custom-label').html('Percentage');
        } else {
            $('.custom-label').html('Amount');
        }
    }
    

  • 注意:如果您的项目中包含I18N支持,您可能需要将标签保存在某个变量中并使用它们。

    使用javascript/jqueryWhere添加标签类?如果您询问的是第2点,它只是HTML。在您希望标签显示的位置使用它,例如刚好在Vendor Commision字段之前。如果是其他问题,我需要一些关于你的问题的细节来回答
    var onChangeFunc = function(event) {
        if($(fixedOrPercentagevendorSelector).val() == 1) {
            $('.custom-label').html('Percentage');
        } else {
            $('.custom-label').html('Amount');
        }
    }