<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
<script type="text/javascript" src="Ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="Ext/ext-all.js"></script>
<script type="text/javascript" src="Ext/ext-basex.js"></script>
<link rel="stylesheet" type="text/css" href="Ext/resources/css/ext-all.css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="button"></div>
<script type="text/javascript">
function ready()
{
var win = new Ext.Window
({
id:"win",
width:300,
height:200,
title:"给单选和复选按钮添加事件",
tbar:
[
{
xtype : 'radio',
id:"check",
boxLabel : '选中',
name : 'flag',
inputValue : '0',
handler:function()//添加事件
{
var check= Ext.getCmp("check");
if(check&&check.checked)
{
Ext.Msg.alert("提示消息","你选择的是["+check.boxLabel+"]");
}
}
},
'',
{
xtype : 'radio',
id:"noCheck",
boxLabel : '不合格',
name : 'flag',
inputValue : '0',
listeners:{"check":function()//添加事件
{
var noCheck= Ext.getCmp("noCheck");
if(noCheck&&noCheck.checked)
{
Ext.Msg.alert("提示消息","你选择的是["+noCheck.boxLabel+"]");
}
}}
}
],
bbar://debugger;
[
'请选择你的选取爱好','',
{
xtype : 'checkbox',
boxLabel : '玩游戏',
id:"playGame",
inputValue : '0',
listeners:{"check":function()//添加事件
{
var playGame = Ext.getCmp("playGame");
if(playGame&&playGame.checked)
{
Ext.Msg.alert("提示消息","你选择的是["+playGame.boxLabel+"]");
}
}}
},
'',
{
xtype : 'checkbox',
boxLabel : '看电影',
id:"seeFilm",
inputValue : '0',
handler:function()//添加事件
{
var seeFilm = Ext.getCmp("seeFilm");
if(seeFilm&&seeFilm.checked)
{
Ext.Msg.alert("提示消息","你选择的是["+seeFilm.boxLabel+"]");
}
}
},
'',
{
xtype : 'checkbox',
boxLabel : '踢足球',
id:"playFoot",
inputValue : '0'
}
]
});
win.show();
//为踢足球添加事件
var playFoot = Ext.getCmp("playFoot");
playFoot.addListener("check",function()//添加事件
{
if(playFoot&&playFoot.checked)
{
Ext.Msg.alert("提示消息","你选择的是["+playFoot.boxLabel+"]");
}
});
}
Ext.onReady(ready);
</script>
</div>
</form>
</body>
</html>
给单选和复选按钮添加事件
最新推荐文章于 2022-01-20 13:58:46 发布