コンボボックスの内容を読み出す
説明
コンボボックスの内容を読み出すにはコンボボックスオブジェクトのgetValue()メソッドを使います。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="ja">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="../../../lib/resources/css/ext-all.css" type="text/css" media="all">
<link rel="stylesheet" href="../../../lib/resources/css/main.css" type="text/css" media="all">
<script type="text/javascript" src="../../../lib/js/ext-base.js"></script>
<script type="text/javascript" src="../../../lib/js/ext-all.js"></script>
<script type="text/javascript"><!--
Ext.EventManager.on(window, "load", function(){
var store = new Ext.data.SimpleStore({
fields : ["OS","osValue"],
data : [
["MacOS X","mac"],
["Windows XP","windowsxp"],
["Windows Vista","windowsvista"],
["Linux","unix"],
["FreeBSD","unix"]
]
});
combo = new Ext.form.ComboBox({
store : store,
applyTo : "OSname",
displayField : "OS",
mode : "local",
triggerAction : "all",
emptyText : "使用OSを選択してください"
});
combo.on("change", function(){
Ext.get("result").dom.innerHTML = "内容は「"+combo.getValue()+"」です";
});
});
// --></script>
</head>
<body>
<h1>コンボボックスの内容を読み出す</h1>
<form>
<input type="text" id="OSname" name="OSname">
</form>
<div id="result"></div>
</body>
</html>