请教一个javascript保存用户输入的问题 你这个逻辑有点混乱, 服务器的代码在输出HTML时已经执行了. 你的保存按钮是个button还是submit? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 说白了,我就是想点一个按钮,然后保存一点东西罢了因为不懂JavaScript,老大门能否给点代码?谢谢先 那你就用form提交,不用javascript也行, 按钮type="submit" 使用AJAX吧,FIREFOX可能不支持。<!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 runat="server"> <title>无标题页</title><script type="text/javascript">var xmlhttp;function Validation(){ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); var name=document.getElementById("Text1"); xmlhttp.open("Post","AJAXProcessor.aspx?name="+name.value); xmlhttp.onreadystatechange=OnMessageBack; xmlhttp.send(null);}function OnMessageBack(){ if(xmlhttp.readystate==4&&xmlhttp.status==200) { document.write(xmlhttp.responsetext); }}</script></head><body> <form id="form1" runat="server"> <div> <input id="Text1" type="text" /><input id="Button1" type="button" value="button" onclick="Validation();" /> </div> </form></body></html>string ReAction = this.Request.QueryString["Action"];//这是你从页面上请求来的值SqlConnection Conn = new SqlConnection(“连接字符串");Conn.Open();SqlCommand Cmd = new SqlCommand();Cmd.Connection = Conn;Cmd.CommandText = "更新字符串";Cmd.ExecuteNonQuery();Conn.Close(); 请问一下,上面的代码放到jsp里面可以跑吗还有个问题,用户输入的东西保存到哪里去了?谢谢 TO:5楼完善5楼的。var xmlHttp=false;try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e2){xmlHttp=false;}}if(!xmlHttp && XMLHttpRequest!='undefined'){xmlHttp=new XMLHttpRequest();}另外采取post提交数据时,在处理页面用Request.Form[]接受数据... 如何拿到SWFUpload addBtn 的点击事件 js 仿 marquee 能实现左右滚动并控制次数吗 想问一个问题 JS初学者菜鸟问题 请教,elong.com预订机票的程序问题 求命呀,,急!!在线等 请问一个颜色的小问题.新手,求救!!各位大哥! 请教:如何使用javascript将图片旋转90度? 怎样在点击窗口右上方关闭按钮时弹出警告框??在线等!! 关于选项卡的一个问题实在是解决不了了,求助 关于区分单击和双击的问题 execCommand 获取
<!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 runat="server">
<title>无标题页</title>
<script type="text/javascript">
var xmlhttp;
function Validation()
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
var name=document.getElementById("Text1");
xmlhttp.open("Post","AJAXProcessor.aspx?name="+name.value);
xmlhttp.onreadystatechange=OnMessageBack;
xmlhttp.send(null);
}
function OnMessageBack()
{
if(xmlhttp.readystate==4&&xmlhttp.status==200)
{
document.write(xmlhttp.responsetext);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Text1" type="text" /><input id="Button1" type="button" value="button" onclick="Validation();" />
</div>
</form>
</body>
</html>
string ReAction = this.Request.QueryString["Action"];//这是你从页面上请求来的值
SqlConnection Conn = new SqlConnection(“连接字符串");
Conn.Open();
SqlCommand Cmd = new SqlCommand();
Cmd.Connection = Conn;
Cmd.CommandText = "更新字符串";
Cmd.ExecuteNonQuery();
Conn.Close();
还有个问题,用户输入的东西保存到哪里去了?谢谢
完善5楼的。var xmlHttp=false;
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e2)
{
xmlHttp=false;
}
}
if(!xmlHttp && XMLHttpRequest!='undefined')
{
xmlHttp=new XMLHttpRequest();
}另外采取post提交数据时,在处理页面用Request.Form[]接受数据...