0
我需要检索选中的单选按钮的值并将其作为参数发送到窗体。我写了下面的代码块,但每次只传递第一个值。有人可以帮忙吗?ExtJS单选按钮值检索
Ext.onReady(function() {
Ext.getCmp('myButton').setHandler(function(){
Ext.MessageBox.show({
title: 'Hello',
msg: 'Please choose one? <br></br> Select: '+
'<input type="radio" name="newrate" value="Yes" checked /> Yes'+
'<input type="radio" name="newrate" value="No" /> No',
buttons: Ext.MessageBox.OKCANCEL,
fn: function(btn) {
if(btn == 'ok') {
alert(Ext.get('newrate').getValue());
var form = Ext.getCmp("MyForm").getForm();
form.getEl().dom.action="${pageContext.request.contextPath}/peer.online.MyForm.grid.action?mode=StornoDX&value="+Ext.get('newrate').getValue();
form.getEl().dom.method="POST";
form.getEl().dom.submit();
}
}
});
});
});
感谢Ankit的答案。还有一个问题,因为我看到这有一些浏览器的限制。它在Chrome上适用于我,但在IE8上遇到了问题。有没有其他方法可以在所有浏览器上运行? –
哦..问题是IE 8不支持':checked' CSS选择器。所以我们需要循环单选按钮并找到选中的值。我已经更新了我的答案 –
非常感谢。这解决了我的问题。 –