如何用ASP来接收HTML表单中的数据? 5
HTML如下。请问对应SaveData.asp应如何编写?<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"...
HTML如下。请问对应SaveData.asp应如何编写?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="robots" content="all" />
<title>[微博投稿系统]</title>
<SCRIPT language="javascript">
<!--
function checktext(text)
{
allValid = true;
for (i = 0; i < text.length; i++)
{
if (text.charAt(i) != " ")
{
allValid = false;
break;
}
}
return allValid;
}
function gbcount(message,total,used,remain)
{
var max;
max = total.value;
if (message.value.length > max) {
message.value = message.value.substring(0,max);
used.value = max;
remain.value = 0;
alert("留言不能超过 140 个字!");
}
else {
used.value = message.value.length;
remain.value = max - used.value;
}
}
-->
</script>
<style type="text/css">
<!--
* {padding:0; margin:0;}
body, html {text-align:left; font-size:12px; line-height:150%; margin:0 auto; background:#fff; padding-top:20px;}
fieldset {padding:10px; width:550px; margin:0 auto;}
legend {font-size:14px; font-weight:bold;}
.inputtext {border:none; background:#fff;}
-->
</style>
</head>
<body>
<form action="SaveData.asp" method="post" onSubmit="return datacheck();">
<h2 align="center"><br>
<br>
<br>
<h1 align="center"><font color="#008000">微博投稿系统</font></b><br></h1>
<br>
<br>
<fieldset><legend><font color="#0000FF">请输入您 投稿/荐稿 的微博内容</font></legend>
<textarea name="Memo" rows="10" wrap=PHYSICAL cols="75" onKeyDown="gbcount(this.form.Memo,this.form.total,this.form.used,this.form.remain);" onKeyUp="gbcount(this.form.Memo,this.form.total,this.form.used,this.form.remain);"></textarea>
<p>最多字数:
<input disabled maxLength="4" name="total" size="3" value="140" class="inputtext">
已用字数:
<input disabled maxLength="4" name="used" size="3" value="0" class="inputtext">
剩余字数:
<input disabled maxLength="4" name="remain" size="3" value="140" class="inputtext"></td>
</p>
<br><h5 align="left">
希望您可以留下联系方式方便我们交流,如E-mail/QQ/Tel:</h5>
<input type="text" name="textone" size=75><br>
<br><h5 align="center">
<input type="submit" name="buttonone" value="投稿/荐稿" checked onclick="">
<br>
<br></h5>
</fieldset>
</form>
</body>
</html> 展开
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="robots" content="all" />
<title>[微博投稿系统]</title>
<SCRIPT language="javascript">
<!--
function checktext(text)
{
allValid = true;
for (i = 0; i < text.length; i++)
{
if (text.charAt(i) != " ")
{
allValid = false;
break;
}
}
return allValid;
}
function gbcount(message,total,used,remain)
{
var max;
max = total.value;
if (message.value.length > max) {
message.value = message.value.substring(0,max);
used.value = max;
remain.value = 0;
alert("留言不能超过 140 个字!");
}
else {
used.value = message.value.length;
remain.value = max - used.value;
}
}
-->
</script>
<style type="text/css">
<!--
* {padding:0; margin:0;}
body, html {text-align:left; font-size:12px; line-height:150%; margin:0 auto; background:#fff; padding-top:20px;}
fieldset {padding:10px; width:550px; margin:0 auto;}
legend {font-size:14px; font-weight:bold;}
.inputtext {border:none; background:#fff;}
-->
</style>
</head>
<body>
<form action="SaveData.asp" method="post" onSubmit="return datacheck();">
<h2 align="center"><br>
<br>
<br>
<h1 align="center"><font color="#008000">微博投稿系统</font></b><br></h1>
<br>
<br>
<fieldset><legend><font color="#0000FF">请输入您 投稿/荐稿 的微博内容</font></legend>
<textarea name="Memo" rows="10" wrap=PHYSICAL cols="75" onKeyDown="gbcount(this.form.Memo,this.form.total,this.form.used,this.form.remain);" onKeyUp="gbcount(this.form.Memo,this.form.total,this.form.used,this.form.remain);"></textarea>
<p>最多字数:
<input disabled maxLength="4" name="total" size="3" value="140" class="inputtext">
已用字数:
<input disabled maxLength="4" name="used" size="3" value="0" class="inputtext">
剩余字数:
<input disabled maxLength="4" name="remain" size="3" value="140" class="inputtext"></td>
</p>
<br><h5 align="left">
希望您可以留下联系方式方便我们交流,如E-mail/QQ/Tel:</h5>
<input type="text" name="textone" size=75><br>
<br><h5 align="center">
<input type="submit" name="buttonone" value="投稿/荐稿" checked onclick="">
<br>
<br></h5>
</fieldset>
</form>
</body>
</html> 展开
1个回答
展开全部
在SaveData.asp这样写就可以得到了
request.Form("total")
request.Form("total")
追问
其实我还想储存下来。
追答
得先建一个数据库 access、sqlserver或者其它的数据库
建立数据连接,
set conn = server.createobject("adodb.connection")
以下为sqlserver
application("StrConnString") ="Provider=SQLOLEDB.1;User ID=sa;Initial Catalog=数据库名;Data Source=数据库;password=密码"
//access数据库
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source='"&Server.MapPath("/")&"\access数据库文件'"
conn.open application("StrConnString")
sql="insert into 表名(列名) values(列名对就获取到的值)"
conn.execute(sql)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询