怎样定时自动提交如下表单?

SunshineRide 2003-09-08 05:52:33
<form action=index1.asp method=post name=sendvalue>
<input type=text name=username>
<input type=password name=password>
</form>

要求是,每隔一秒种就自动提交一次。最好是不要看到提交的内容。就象在后台运行一样。该如何做呢?提交的时候,该页面是不能离开的。。。
...全文
222 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
possible_Y 2003-09-08
  • 打赏
  • 举报
回复
第一种方法是用xmlhttp,无刷新的向后台发送数据,客户端没有任何感觉

第二种是将表单提交到一个隐藏的iframe里,这样页面基本没有变化,但是浏览器下面的进度条会不停的散动,而且会有“哒”的声音
possible_Y 2003-09-08
  • 打赏
  • 举报
回复
或者:
<body onload='setInterval("sendvalue.submit()",1000)'>
<form action=getdata.asp method=post name=sendvalue target="iframe1">
<input type=text name=username>
<input type=password name=password>
</form>
<iframe name="iframe1" heihgt="0" width="0"></iframe>
</body>
possible_Y 2003-09-08
  • 打赏
  • 举报
回复
<script>
function sendData(){
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("POST", "index1.asp?username="+sendvalue.username.value+"&password="+sendvalue.password.value", false);
xmlhttp.Send("");
setTimeout("sendData()",1000);
}
</script>
<body onload="sendData()">

</body>
windancer 2003-09-08
  • 打赏
  • 举报
回复
我的按钮只是用来触发以下而已,以后自动每秒提交一次
你把按钮的onclick写在body的onload事件里不久可以了吗
SunshineRide 2003-09-08
  • 打赏
  • 举报
回复
to windancer(风精灵):
首先,谢谢你的热心,但我要的是自动提交,而不是点击后提交。点击后提交,也就不要你那么麻烦了。。。

我找到一个代码段,是这样的。

<form action=getdata.asp method=post name=sendvalue>
<input type=text name=username>
<input type=password name=password>
</form>
<script language=javascript>
setInterval("document.sendvalue.submit()",1000)
</script>

有人这样可以,但在我的机器上却提示错误,说“对象不支持此属性或方法”.到底该怎么做呢?我想让它每隔比如三秒种就自动提交一次,而且还不能离开该提交页面就把数据送出去。可以做到吗?
Aa7643 2003-09-08
  • 打赏
  • 举报
回复
我也想知道:
比如用用户名和密码登陆到一个社区,当社区人数过多而不能登陆时(社区会弹出一个MSGBOX叫你返回histroy.back();),然后返回自动重新登陆,这样不知道怎么样做????
windancer 2003-09-08
  • 打赏
  • 举报
回复
不知道你要做什么,只能给你作个示例,
我在index1.asp里就写了一个<%=request("password")%>,能够取到值
windancer 2003-09-08
  • 打赏
  • 举报
回复
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<script language="JavaScript" type="text/JavaScript">
function Login(username,password)
{
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")
xmlHttp.open("POST", "index1.asp?username="+username+"&password="+password,false)
xmlHttp.send()
var re=xmlHttp.responseText;
alert(re);
setTimeout("Login(sendvalue.username.value,sendvalue.password.value)",1000);
}
</script>
<body>
<form method=post name=sendvalue>
<input type=text name=username>
<input type=password name=password>
<input name="ok" type="button" value="提交" onClick="Login(sendvalue.username.value,sendvalue.password.value)">
</form>
</body>
</html>
SunshineRide 2003-09-08
  • 打赏
  • 举报
回复
谁会的呀?帮帮忙啊。。。。
SunshineRide 2003-09-08
  • 打赏
  • 举报
回复
to lpn(夜雨)

你的方法不对。我试过了。根本不提交表单。

谁能给我一个正确的解决方法?最好是使用JAVASCRIPT的setTimeout来解决问题,因为我还需要在不同的时间提交不同的表单。。谢谢了。。。
celerylhl 2003-09-08
  • 打赏
  • 举报
回复
up to you
<iframe src="xxx.asp" >
quady 2003-09-08
  • 打赏
  • 举报
回复
用个iframe去提交。
提交前设置主页面的一个值为false,然后当提交完成后有结果输出时设置为true。你在每个连接都用javascript检测,如果为false,就alert他等,如果true就通过。。。
lpn 2003-09-08
  • 打赏
  • 举报
回复
用JavaScript的document.submit;如果你不想将提交内容显示出来,那么你可以用隐藏域。
试试下面的:

<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="refresh" content="1;url=这个页面的链接地址">
<Script Language="JavaScript">
document.sendvalue.submit();
</Script>
</head>

<body>
<form action=index1.asp method=post name=sendvalue>
<input type=hidden name=username>
<input type=hidden name=password>
</form>
</body>
</html>

其中<meta http-equiv="refresh" content="1;url=这个页面的链接地址">里面的那个content=1就是设定你的页面刷新时间间隔的。
SunshineRide 2003-09-08
  • 打赏
  • 举报
回复
请帮忙解决,第一个解决的,我将给他全部题分。。。谢谢。。。

28,393

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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