| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 669 人关注过本帖
标题:關於動態的行裡控制文本框只能輸入數字的問題?
取消只看楼主 加入收藏
unix
Rank: 1
等 级:新手上路
帖 子:134
专家分:0
注 册:2005-12-28
收藏
 问题点数:0 回复次数:3 
關於動態的行裡控制文本框只能輸入數字的問題?

<!--#include file="chksession.asp"--><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>下一步,工件信息錄入</title>
<%
dim lianluo
lianluo=request.querystring("lianluo")
types=request.querystring("types")

%>
<link href="css.css" rel="stylesheet" type="text/css">

<script language=javascript type=text/javascript>
<!--
var RES_BT_DELETE = "刪除";
var isIE = (navigator.userAgent.indexOf("MSIE") != -1);
var fileIndex = 1;
function addFile() {
var spanId = "filespan";
var fileId = "upload" + (fileIndex++);
addInputFile(spanId, fileId);
}
function addInputFile(spanId, fileId) {
var span = document.getElementById(spanId);
if (span != null) {
var divObj = document.createElement("div"), lianluoObj, indexObj, tuhaoObj, taoObj, cailiaoObj, houObj, kuanObj, gaoObj, duObj, reObj, beizhuObj, delObj;
divObj.id = fileId;
if (isIE) {
lianluoObj = document.createElement("<input type=hidden>");
indexObj = document.createElement("<input type=text>");
tuhaoObj = document.createElement("<input type=text>");
taoObj = document.createElement("<input type=text>");
cailiaoObj = document.createElement("<input type=text>");
houObj = document.createElement("<input type=text>");
kuanObj = document.createElement("<input type=text>");
gaoObj = document.createElement("<input type=text>");
duObj = document.createElement("<input type=text>");
reObj = document.createElement("<input type=text>");
beizhuObj = document.createElement("<input type=text>");
delObj = document.createElement("<input type=button onclick=delInputFile('" + spanId + "','" + fileId + "')>");
} else {
lianluoObj = document.createElement("input");
lianluoObj.type = "hidden";
indexObj = document.createElement("input");
indexObj.type = "text";
tuhaoObj = document.createElement("input");
tuhaoObj.type = "text";
taoObj = document.createElement("input");
taoObj.type = "text";
cailiaoObj = document.createElement("input");
cailiaoObj.type = "text";
houObj = document.createElement("input");
houObj.type = "text";
kuanObj = document.createElement("input");
kuanObj.type = "text";
gaoObj = document.createElement("input");
gaoObj.type = "text";
duObj = document.createElement("input");
duObj.type = "text";
reObj = document.createElement("input");
reObj.type = "text";
beizhuObj = document.createElement("input");
beizhuObj.type = "text";
delObj = document.createElement("input");
delObj.type = "button";
delObj.setAttribute("onclick", "delInputFile('" + spanId + "','" + fileId + "')", 0);
}
lianluoObj.id = "lianluo";lianluoObj.value = '<%=lianluo%>';lianluoObj.name = "lianluo";
indexObj.name = "indexs";indexObj.disabled = true;indexObj.id = "indexs";indexObj.size = "6";indexObj.value = fileIndex;
tuhaoObj.name = "tuhao";tuhaoObj.id = "tuhao";tuhaoObj.size = "18";
taoObj.name = "tao";taoObj.id = "tao";taoObj.size = "8";
cailiaoObj.name = "cailiao";cailiaoObj.id = "cailiao";cailiaoObj.size = "8";
houObj.name = "hou";houObj.id = "hou";houObj.size = "8";
kuanObj.name = "kuan";kuanObj.id = "kuan";kuanObj.size = "8";
gaoObj.name = "gao";gaoObj.id = "gao";gaoObj.size = "8";
duObj.name = "du";duObj.id = "du";duObj.size = "8";
reObj.name = "re";reObj.id = "re";reObj.size = "8";
beizhuObj.name = "beizhu";beizhuObj.id = "beizhu";beizhuObj.size = "20";
delObj.value = RES_BT_DELETE;
divObj.appendChild(lianluoObj);
divObj.appendChild(indexObj);
divObj.appendChild(tuhaoObj);
divObj.appendChild(taoObj);
divObj.appendChild(cailiaoObj);
divObj.appendChild(houObj);
divObj.appendChild(kuanObj);
divObj.appendChild(gaoObj);
divObj.appendChild(duObj);
divObj.appendChild(reObj);
divObj.appendChild(beizhuObj);
divObj.appendChild(delObj);
span.appendChild(divObj);
}
}
function delInputFile(spanId, fileId) {
var span = document.getElementById(spanId);
var divObj = document.getElementById(fileId);
if (span != null && divObj != null) {
span.removeChild(divObj);
}
}
//-->
</script>

<meta content="MSHTML 6.00.2800.1528" name=GENERATOR>
</head>
<body onkeydown="quickadd(event)">
<center>
<h3><strong><font color="#FF0000"> <%=lianluo%> </font></strong></h3>

</center>
<form name="form1" id="form1" action="gj_save.asp?lianluo=<%=lianluo%>&types=<%=types%>" method="post" onSubmit="return checkCnt();">
<table height=20 cellSpacing=1 cellPadding=8 width="90%" align=center>
<tbody>
<tr>
<TD id=filespan noWrap>
<div id=0>
<input name="11" type="text" id="11" size="6" value="序號" disabled><input name="22" type="text" id="22" size="18" value="圖號" disabled><input name="33" type="text" id="33" size="8" value="套" disabled><input name="44" type="text" id="44" size="8" value="材料" disabled><input name="55" type="text" id="55" size="8" value="厚" disabled><input name="66" type="text" id="66" size="8" value="寬" disabled><input name="77" type="text" id="77" size="8" value="長" disabled><input name="88" type="text" id="88" size="8" value="鍍" disabled><input name="99" type="text" id="99" size="8" value="熱" disabled><input name="00" type="text" id="00" size="20" value="備注" disabled>
</div>
<div id=1>
<input name="lianluo" type="hidden" id="linaluo" value="<%=lianluo%>"><input name="indexs" type="text" id="indexs" value="1" size="6" disabled><input name="tuhao" type="text" id="tuhao" size="18"><input name="tao" type="text" id="tao" onKeyUp="javascript:var v=this.value;this.value=this.value.replace(/\D/g,'');if(isNaN(v)&&v.length>0){document.all.jiagong.color='red';}" size="8" maxlength="3"><input name="cailiao" type="text" id="cailiao" size="8"><input name="hou" type="text" id="hou" size="8"><input name="kuan" type="text" id="kuan" size="8"><input name="gao" type="text" id="gao" size="8"><input name="du" type="text" id="du" size="8"><input name="re" type="text" id="re" size="8"><input name="beizhu" type="text" id="beizhu" size="20"><INPUT id=btnAdd onclick=addFile() type=button value=添加>
</div>
</TD>
</tr>
<tr>
<td noWrap align=center>
<input name="submit" type="submit" value="提交">
<input name="reset" type="button" onClick="javascript:window.location.href='grp_write.asp?lianluo=<%=lianluo%>';" value="添加购入品">
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
<script language="JavaScript">
cnt = 0;
function checkCnt(){
document.form1.Submit.disabled=true;
cnt++;
if (cnt!=1){
alert('正在提交數據. Please Wait');
return false;
}
}
function quickadd(event)
{
if(event.altKey && event.keyCode == 83)
{
if (cnt==0){
this.addFile();
}else{
alert('正在提交數據. Please Wait');
}
}
}
</script>

我想控制只能輸入數字,或數字(帶小數位的)

我曾以這樣寫
<input name="tao" type="text" id="tao" onKeyUp="javascript:var v=this.value;this.value=this.value.replace(/\D/g,'');if(isNaN(v)&&v.length>0){document.all.jiagong.color='red';}" size="8" maxlength="3">
這樣只有一行數據時有效果,可是多行數據時,第二行起就不能生效了,怎麼辦呢?

[此贴子已经被作者于2006-3-7 9:24:41编辑过]

搜索更多相关主题的帖子: 文本 
2006-03-07 09:24
unix
Rank: 1
等 级:新手上路
帖 子:134
专家分:0
注 册:2005-12-28
收藏
得分:0 
以下是引用阳光白雪在2006-3-7 12:11:00的发言:
lianluoObj = document.createElement("<input type=hidden>");
indexObj = document.createElement("<input type=text>");
tuhaoObj = document.createElement("<input type=text>");
taoObj = document.createElement("<input type=text>");
cailiaoObj = document.createElement("<input type=text>");
houObj = document.createElement("<input type=text>");
kuanObj = document.createElement("<input type=text>");
gaoObj = document.createElement("<input type=text>");
duObj = document.createElement("<input type=text>");
reObj = document.createElement("<input type=text>");
beizhuObj = document.createElement("<input type=text>");
delObj = document.createElement("<input type=button onclick=delInputFile('" + spanId + "','" + fileId + "')>");

应该加在这段代码的<input>中

taoObj = document.createElement("<input type=text onKeyUp="javascript:var v=this.value;this.value=this.value.replace(/\D/g,'');if(isNaN(v)&&v.length>0){document.all.jiagong.color='red';}" >");

改成這樣也不行喲。而且這樣後,我的快捷鍵AIT+S增加行也不生效了。

2006-03-07 14:31
unix
Rank: 1
等 级:新手上路
帖 子:134
专家分:0
注 册:2005-12-28
收藏
得分:0 
還沒有解決呢
2006-03-13 16:13
unix
Rank: 1
等 级:新手上路
帖 子:134
专家分:0
注 册:2005-12-28
收藏
得分:0 
这些在单行的时候都行,可是我放在javascript就不行了.
2006-03-20 09:47
快速回复:關於動態的行裡控制文本框只能輸入數字的問題?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017583 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved