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

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>
...全文
55 2 点赞 打赏 收藏 举报
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
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>


  • 打赏
  • 举报
回复
相关推荐
发帖
JavaScript
加入

8.5w+

社区成员

Web 开发 JavaScript
申请成为版主
帖子事件
创建了帖子
2017-11-27 04:25
社区公告
暂无公告