gpt4 book ai didi

javascript - extjs:从单选按钮获取校验值

转载 作者:行者123 更新时间:2023-11-30 18:17:51 24 4
gpt4 key购买 nike

我正在使用 radiogroup Yes 和 No。我希望将点击值发送到服务器。如何实现?

我的代码:

{
fieldLabel: 'Striping',
xtype: 'radiogroup',
columns: [50, 100],
items: [{
boxLabel: 'Yes',
name: 'rb',
id: 'stYes',
/*checked: true,*/
inputValue: '1',
listeners: {
click: function () {
alert("Click 2!");
}
}

}, {
boxLabel: 'No',
name: 'rb',
id: 'stNo',
inputValue: '2',
listeners: {
click: function () {
alert("Click 2!");
}
}
}]
}

最佳答案

我认为这样的东西会起作用,我无法测试这个 atm。单选按钮不会出现单击,您需要使用更改事件。另外,您最好将听众放在您的组中。这样您就不必为组中的每个按钮都定义一个监听器。

注意:给组件提供 id 时要小心,使用 itemId 或名称代替。

    {
fieldLabel: 'Striping',
xtype:'radiogroup',
columns: [50, 100],
items: [{
boxLabel: 'Yes',
name: 'rb',
id: 'stYes',
/*checked: true,*/
inputValue: '1'

},
{
boxLabel: 'No',
name: 'rb',
id: 'stNo',
inputValue: '2'
}],
listeners: {
change: function( radiogroup, newValue, oldValue, eOpts ) {
alert(newValue.rb);
}
}
}

fiddle 示例:http://jsfiddle.net/johanhaest/cpLvK/7/

关于javascript - extjs:从单选按钮获取校验值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12835042/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com