怎么实现点哪个框就在那个框输出。。。还有这个小数点怎么显示不了

Illegaler_xxxx 2017-11-27 04:25:16
新手刚上手
<html>
<head>
<script language="javascript" type="text/javascript">
function btnNum_onclick(i)
{
var a1 = txtNum.value;
if(a1.length < 6)
{
txtNum.value = txtNum.value + i;
}
else
{
return;
}
}
function btnDelete_onclick()
{
var a2 = txtNum.value;
a2 = a2.substring("",a2.length - 1);
txtNum.value = a2;
}
</script>
</head>
<body>
<div >
<input id="txtNum" type="test" style="position:absolute; top:205px; width: 250px; height: 50px;"/>
<input id="txtNum1" type="test" style="position:absolute; top:305px; width: 250px; height: 50px;"/>
<div style="position:absolute;">
<input id="Button1" type="button" value="1" style="width: 60px; height: 60px;" onclick="return btnNum_onclick(1)" />
<input id="Button." type="button" value="." style="width: 60px; height: 60px;" onclick="return btnNum_onclick(.)" />
<input id="ButtonD" type="button" value="删除" style="width: 60px; height: 60px;" onclick="return btnDelete_onclick()"/>
</div>
</div>
</body>
</html>
...全文
103 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Illegaler_xxxx 2017-11-27
  • 打赏
  • 举报
回复
好牛逼啊
天际的海浪 2017-11-27
  • 打赏
  • 举报
回复


<html>
<head>
    <script language="javascript" type="text/javascript">
	    var txtObj;
	    window.onload = function () {
	    	txtObj = document.getElementById("txtNum");
	    }

        function btnNum_onclick(i)
		{
			var a1 = txtObj.value;
			if(a1.length < 6)
			{
				txtObj.value = txtObj.value + i;				
			}
			else
			{
				return;
			}
        }
		function btnDelete_onclick()
		{
			var a2 = txtObj.value;
			a2 = a2.substring("",a2.length - 1);
			txtObj.value = a2;		
		}
    </script>	
</head>
<body>
	<div >
		<input id="txtNum" type="test" style="position:absolute; top:205px; width: 250px; height: 50px;" onfocus="txtObj=this"/>
		<input id="txtNum1" type="test" style="position:absolute; top:305px; width: 250px; height: 50px;" onfocus="txtObj=this"/>
		<div style="position:absolute;">
			<input id="Button1" type="button" value="1" style="width: 60px; height: 60px;" onclick="return btnNum_onclick('1')" />
			<input id="Button." type="button" value="." style="width: 60px; height: 60px;" onclick="return btnNum_onclick('.')" />
			<input id="ButtonD" type="button" value="删除" style="width: 60px; height: 60px;" onclick="return btnDelete_onclick()"/>
		</div>
	</div>
</body>
</html>


87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧