如题所述
å¯ä»¥ä½¿ç¨selectæ¡çonchangeå±æ§ï¼ç»å®å¼å¨ååå使ç¨å½æ°å¤çãå
å¨æçæselectãä¸é¢æ¯ä¾åï¼<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn">
<head>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<title>ä¸ææ¡å 容èªå¨å¡«å ææ¬æ¡</title>
<link href="" type="text/css" rel="stylesheet" />
<script type="text/javascript" language="javascript" src=""></script> <style type="text/css"> </style>
<script type="text/javascript" language="javascript">
function ChangeTxt(obj){
var val = obj.options[obj.selectedIndex].value; //è·åä¸æ¥æ¡éæ©çå¼
document.getElementById("inptxt").value=val; //å°è·åçå¼å¡«åå°ææ¬æ¡
}
</script>
</head> <body>
<input type="text" name="inptxt" id="inptxt" value=""><select id="sel" name="sel" onchange="ChangeTxt(this)">
<option value="项ç®1">项ç®1</option>
<option value="项ç®2">项ç®2</option>
<option value="项ç®3">项ç®3</option>
<option value="项ç®4">项ç®4</option>
</select>
</body>
</html>æ¼ç¤ºç½åï¼ http://www.qkweb.net/demo/js/form/ChangeSelectToText.html
<html xmlns=" http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn">
<head>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<title>ä¸ææ¡å 容èªå¨å¡«å ææ¬æ¡</title>
<link href="" type="text/css" rel="stylesheet" />
<script type="text/javascript" language="javascript" src=""></script> <style type="text/css"> </style>
<script type="text/javascript" language="javascript">
function ChangeTxt(obj){
var val = obj.options[obj.selectedIndex].value; //è·åä¸æ¥æ¡éæ©çå¼
document.getElementById("inptxt").value=val; //å°è·åçå¼å¡«åå°ææ¬æ¡
}
</script>
</head> <body>
<input type="text" name="inptxt" id="inptxt" value=""><select id="sel" name="sel" onchange="ChangeTxt(this)">
<option value="项ç®1">项ç®1</option>
<option value="项ç®2">项ç®2</option>
<option value="项ç®3">项ç®3</option>
<option value="项ç®4">项ç®4</option>
</select>
</body>
</html>æ¼ç¤ºç½åï¼ http://www.qkweb.net/demo/js/form/ChangeSelectToText.html
温馨提示:答案为网友推荐,仅供参考