怎样只提交form中的部分元素?

zengchangliu 2003-10-10 05:16:34
我在录入或者修改一个班级的学生成绩的时候。不想在录入完成后全部提交,没有修改的没有必要提交和在数据库中更新。我只想提交修改过的text。请给点意见。

另外我还要限制用户输入的必须是数字,在提交的时候判断是不科学的,因为有很多行输入,最好是在输入框的onchange事件中,就不让用户按下出数字键以外的键。

如果大家有更好的解决方案请不吝赐教。我多给分

...全文
321 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
liad 2003-10-12
  • 打赏
  • 举报
回复
补充一下楼上的
<table>
<tr>
<td><input type="text" name=""></td>
<td><input type="text" name=""></td>
<td><a href="#" tabIndex="-1">oo</a></td>
</tr>
<tr>
<td><input type="text" name=""></td>
<td><input type="text" name=""></td>
<td><a href="#" tabIndex="-1">00</a></td>
</tr>
</table>



tabIndex

--------------------------------------------------------------------------------

Description

Sets the tab index for the object.

Syntax
object.tabIndex[ = tabIndex]


Remarks

Tab selection order is determined by the value of tabIndex as follows:

All elements with tabIndex > 0 are selected in increasing tab index order, or in source order for duplicate tab index values.
All elements with tabIndex = 0, or without tabIndex set, are selected next, in source order if more than one.
Elements with tabIndex = -1 are omitted from tabbing order.
This property has read-write permissions, meaning you can change as well as retrieve its current value.

Applies To

A, APPLET, AREA, BODY, BUTTON, DIV, EMBED, HR, IFRAME, IMG, INPUT, MARQUEE, OBJECT, SELECT, TABLE, TEXTAREA

swinging 2003-10-12
  • 打赏
  • 举报
回复
对于第三个问题,一个简单例子:
<html>
<head>
<title> New Document </title>
</head>
<script language="JavaScript">
<!--
window.document.attachEvent("onkeydown" , function(){
if(window.event.keyCode==13){
window.event.keyCode = 9;
}
});
//-->
</script>
<body>
<table>
<tr>
<td><input type="text" name=""></td>
<td><input type="text" name=""></td>
</tr>
<tr>
<td><input type="text" name=""></td>
<td><input type="text" name=""></td>
</tr>
</table>
</body>
</html>
squallzeng 2003-10-12
  • 打赏
  • 举报
回复
这是下一个问题了,应该另外给分。哈哈
zengchangliu 2003-10-11
  • 打赏
  • 举报
回复
第三个问题出来了。怎么能够在这里面,控制焦点的位置,我在输入一个成绩之后,enter
能不能条转到下一个输入
realby 2003-10-11
  • 打赏
  • 举报
回复
up
tripofdream 2003-10-10
  • 打赏
  • 举报
回复
if(document.form1.text1.value == document.form1.text1.defaultValue){
document.form1.text1.disabled = true;
}

onkeypress
onblur
aku0708 2003-10-10
  • 打赏
  • 举报
回复
用下面的代码:
<SCRIPT LANGUAGE="JavaScript">
//<!--
function onlynumber(str)//判断是否只是数字
{
var i,strlength,tempchar;
strlength=str.length;
for(i=0;i<strlength;i++)
{
tempchar=str.substring(i,i+1);
if(!(tempchar==0||tempchar==1||tempchar==2||tempchar==3||tempchar==4
||tempchar==5||tempchar==6||tempchar==7||tempchar==8||tempchar==9))
{
alert('只能输入数字');
str="1";
break;
}
}
return str;
}
//-->
+++++
不想把部分信息提交,可以用楼上的这位大哥的方法
kevincom 2003-10-10
  • 打赏
  • 举报
回复
给你个函数,解决你第二个问题:
function regInput(obj, reg, inputStr) {
var docSel = document.selection.createRange()
if (docSel.parentElement().tagName != "INPUT") return false
oSel = docSel.duplicate()
oSel.text = ""
var srcRange = obj.createTextRange()
oSel.setEndPoint("StartToStart", srcRange)
var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
return reg.test(str)
}

如下使用:
<input name="rDoc_recCount" type="text" class="input2" onkeypress = "return regInput(this,/^[0-9]*$/,String.fromCharCode(event.keyCode))" onpaste = "return regInput(this,/^[0-9]*$/, window.clipboardData.getData('Text'))" ondrop = "return regInput(this,/^[0-9]*$/,event.dataTransfer.getData('Text'))" style="ime-mode:Disabled">
liad 2003-10-10
  • 打赏
  • 举报
回复
不想提交的元素,你在提交的时候用javascript把对应的input的disabled属性设为true,就不会提交了。

document.form1.text1.disabled = true;

81,092

社区成员

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

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