主要代码如下: <script type="text/javascript">
Ext.onReady(function(){ Ext.create('Ext.form.Panel', {
bodyPadding: 10,
width : 300,
title : 'Pizza Order',
items: [
{
xtype : 'fieldcontainer',
fieldLabel : 'Toppings',
defaultType: 'checkboxfield',
items: [
{
boxLabel : 'Anchovies',
name : 'topping',
inputValue: '1',
id : 'checkbox1'
}, {
boxLabel : 'Artichoke Hearts',
name : 'topping',
inputValue: '2',
checked : true,
id : 'checkbox2'
}, {
boxLabel : 'Bacon',
name : 'topping',
inputValue: '3',
id : 'checkbox3'
}
]
}
],
renderTo: Ext.getBody()
}); var array1 = document.getElementsByName("topping");alert(array1);alert(array1.length);// 要实现类似这样的功能,这里无效
var array2 = Ext.query("*[name=topping]");alert(array2);alert(array2.length);//用query也无 效,array值为“”
});
</script> 再补充说明下,就是想通过复选框的name值topping来求其数组,这里我用了两种方式,都无效, document.getElementsByName("topping");是普通js中使用的,另一种是ext中使用的,我用了query,也无效,不知 道问题出在哪里了?
Ext.onReady(function(){ Ext.create('Ext.form.Panel', {
bodyPadding: 10,
width : 300,
title : 'Pizza Order',
items: [
{
xtype : 'fieldcontainer',
fieldLabel : 'Toppings',
defaultType: 'checkboxfield',
items: [
{
boxLabel : 'Anchovies',
name : 'topping',
inputValue: '1',
id : 'checkbox1'
}, {
boxLabel : 'Artichoke Hearts',
name : 'topping',
inputValue: '2',
checked : true,
id : 'checkbox2'
}, {
boxLabel : 'Bacon',
name : 'topping',
inputValue: '3',
id : 'checkbox3'
}
]
}
],
renderTo: Ext.getBody()
}); var array1 = document.getElementsByName("topping");alert(array1);alert(array1.length);// 要实现类似这样的功能,这里无效
var array2 = Ext.query("*[name=topping]");alert(array2);alert(array2.length);//用query也无 效,array值为“”
});
</script> 再补充说明下,就是想通过复选框的name值topping来求其数组,这里我用了两种方式,都无效, document.getElementsByName("topping");是普通js中使用的,另一种是ext中使用的,我用了query,也无效,不知 道问题出在哪里了?
解决方案 »
- document.formName.name与 document.getElementById的区别
- 请教,prototype中的一段代码看不明白!
- 求一个JAVASCRIPT代码,可以输入数据的SELECT
- 为什么我的这个函数这么慢?
- 紧急求救,解决后立刻给分!我的IE在访问某个网站时提示“Your need to enable javascript in your browser” 然后就显示空白。怎么解决
- 如何在asp页面中 浮动出一个框来,询问是否要将本站加为首页。类似于sina前段时间的显示
- 关于图片拖动时的抖动问题请教
- 按钮总不能响应onclick()事件?
- 简单问题,急救,狂给分
- JavaScript中哪个函数判断一字符串是否是日期?急用!!!
- jquery的导航问题
- jquery scrollTop offset().top
alert(v);复制上看看什么反应
给你专门写了个方法 可以根据name拿到所有checkbox
function getCheckBoxByName(name) {
var arr = [];
Ext.form.CheckboxManager.getByName(name).each(function(cb) {
arr.push(cb)
});
alert(arr.length)
}
我感觉应该这样
xtype : 'checkboxgroup',
fieldLabel : 'Toppings',
// defaultType: 'checkboxfield',
items: [
]