告急,字符的输入。 别用onpropertychange,否则你每输入一个数字都会触发时间,还有你的input和div的name和id不要同时用“a”表示可能更好一些 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 洛林bro,不好意思,洗完澡才看到你的问题ps: 明天在家里看球写了个例子,看看是不是你想要的效果在IE 6.0 SP1下测试通过-------------------------------------------------------------<html><head><title> New Document </title><meta name="Generator" content="EditPlus"><meta name="Author" content=""><meta name="Keywords" content=""><meta name="Description" content=""><script language="JavaScript"><!--var s_intCurrentMonth; //当前的月份//初始化页面function initPage(){ //更新当前的月份 s_intCurrentMonth = 1; updateCurrentMonth(); document.frmMain.txtScore.focus();}//将输入的分数和相应的月份加入到显示列表中function addScoreToShowList(){ //当用户按了回车键(键码为13)时 if (event.keyCode == 13) { //当分数输入框中有内容时 if (document.frmMain.txtScore.value != "") { var strShow; //要显示的内容 //将输入的分数和相应的月份加入到显示列表中 strShow = s_intCurrentMonth + "月份: " + document.frmMain.txtScore.value + "分<br>"; divShowList.innerHTML += strShow; //更新当前的月份 s_intCurrentMonth ++; if (s_intCurrentMonth <= 12) { updateCurrentMonth(); document.frmMain.txtScore.value = ""; document.frmMain.txtScore.focus(); } else { document.frmMain.txtScore.value = ""; document.frmMain.txtScore.disabled = true; document.frmMain.txtScore.style.backgroundColor = "#a9a9a9"; } } //这句话的加入是为了解决当1个表单只包含1个文本框时 //在文本框中按回车会自动提交表单的问题 //如果你不用表单或表单中没有或有1个以上的文本框时 //这句话可以不写 event.returnValue = false; }}//更新当前的月份function updateCurrentMonth(){ lblCurrentMonth.innerText = s_intCurrentMonth;}//--></script></head><body onLoad="javaScript: initPage();"><form name="frmMain" method="post" action="">请输入<label id="lblCurrentMonth"></label>月份的分数<br><input type="text" name="txtScore" onKeyPress="javaScript: addScoreToShowList();"><div id="divShowList"></div></form></body></html> 求助JS效果:像百度搜索框一样,在文本框中输入字符后,自动出现提示下拉框 求助!js 复选框树 jQuery的问题 一个简单的问题? b为什么还在关联 ??? 大家看看这种城市地图是用什么技术做的? http://www.fsecity.com 请教一个JS判断函数 用正则表达式提取文件名的问题 要判断一字符串中有没有", /,等特殊字符的时候用到的转意字符是什么啊? 需要一份js代码实现图片轮播、二级菜单、下拉菜单、鼠标悬停提示、输入输出框 关于层?? 求助:怎么在JS文件中用document.writeln语句写入含字符变量的 链接点 ???
ps: 明天在家里看球写了个例子,看看是不是你想要的效果
在IE 6.0 SP1下测试通过
-------------------------------------------------------------<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script language="JavaScript">
<!--
var s_intCurrentMonth; //当前的月份//初始化页面
function initPage()
{
//更新当前的月份
s_intCurrentMonth = 1;
updateCurrentMonth(); document.frmMain.txtScore.focus();
}//将输入的分数和相应的月份加入到显示列表中
function addScoreToShowList()
{
//当用户按了回车键(键码为13)时
if (event.keyCode == 13)
{
//当分数输入框中有内容时
if (document.frmMain.txtScore.value != "")
{
var strShow; //要显示的内容 //将输入的分数和相应的月份加入到显示列表中
strShow = s_intCurrentMonth + "月份: " + document.frmMain.txtScore.value + "分<br>";
divShowList.innerHTML += strShow;
//更新当前的月份
s_intCurrentMonth ++;
if (s_intCurrentMonth <= 12)
{
updateCurrentMonth(); document.frmMain.txtScore.value = "";
document.frmMain.txtScore.focus();
}
else
{
document.frmMain.txtScore.value = "";
document.frmMain.txtScore.disabled = true;
document.frmMain.txtScore.style.backgroundColor = "#a9a9a9";
}
} //这句话的加入是为了解决当1个表单只包含1个文本框时
//在文本框中按回车会自动提交表单的问题
//如果你不用表单或表单中没有或有1个以上的文本框时
//这句话可以不写
event.returnValue = false;
}
}//更新当前的月份
function updateCurrentMonth()
{
lblCurrentMonth.innerText = s_intCurrentMonth;
}
//-->
</script>
</head><body onLoad="javaScript: initPage();">
<form name="frmMain" method="post" action="">
请输入<label id="lblCurrentMonth"></label>月份的分数<br>
<input type="text" name="txtScore" onKeyPress="javaScript: addScoreToShowList();">
<div id="divShowList"></div>
</form>
</body>
</html>