这是我的一个按钮onclick的函数:
function addstu(){
var str1=document.myform.1.value; //document.getElementById("1").value;
var str2=document.myform.2.value; //document.getElementById("2").value;
var str3=document.myform.3.value; //document.getElementById("3").value;
var str4=document.myform.4.value; //document.getElementById("4").value;
var str5=document.myform.5.value; //document.getElementById("5").value;
alert("运行到这里了!");
if(str1==""||str2==""||
str3==""||str4==""||str5=="")
{
alert("请完善信息!");
return false;
}
var str="StuServletst?uname=str1&stusno=str2&stuage=str3&stusex=str4&studept=str5";
send_request(str);//这里是传给ajax处理的
}
当我点击按钮时,没反应,必须要把var str1=document.myform.1.value; //document.getElementById("1").value;
var str2=document.myform.2.value; //document.getElementById("2").value;
var str3=document.myform.3.value; //document.getElementById("3").value;
var str4=document.myform.4.value; //document.getElementById("4").value;
var str5=document.myform.5.value; //document.getElementById("5").value;
这删掉才会弹出alert;
还有就是var str="StuServletst?uname=str1&stusno=str2&stuage=str3&stusex=str4&studept=str5";
send_request(str);//这里是传给ajax处理的
这句能传给ajax再传给服务器吗?
初学这些,还是在自学的,老师都没讲,喊我们用这做课程设计。遇到很多问题啊~~~烦~哪位大侠能解决下,万分感谢!
function addstu(){
var str1=document.myform.1.value; //document.getElementById("1").value;
var str2=document.myform.2.value; //document.getElementById("2").value;
var str3=document.myform.3.value; //document.getElementById("3").value;
var str4=document.myform.4.value; //document.getElementById("4").value;
var str5=document.myform.5.value; //document.getElementById("5").value;
alert("运行到这里了!");
if(str1==""||str2==""||
str3==""||str4==""||str5=="")
{
alert("请完善信息!");
return false;
}
var str="StuServletst?uname=str1&stusno=str2&stuage=str3&stusex=str4&studept=str5";
send_request(str);//这里是传给ajax处理的
}
当我点击按钮时,没反应,必须要把var str1=document.myform.1.value; //document.getElementById("1").value;
var str2=document.myform.2.value; //document.getElementById("2").value;
var str3=document.myform.3.value; //document.getElementById("3").value;
var str4=document.myform.4.value; //document.getElementById("4").value;
var str5=document.myform.5.value; //document.getElementById("5").value;
这删掉才会弹出alert;
还有就是var str="StuServletst?uname=str1&stusno=str2&stuage=str3&stusex=str4&studept=str5";
send_request(str);//这里是传给ajax处理的
这句能传给ajax再传给服务器吗?
初学这些,还是在自学的,老师都没讲,喊我们用这做课程设计。遇到很多问题啊~~~烦~哪位大侠能解决下,万分感谢!
解决方案 »
- 非常简单的JS可编辑表格,帮忙看下
- iframe用js刷新的困惑
- 下拉列表框中的选项问题
- replace的问题 对您可能简单,对我可就难了
- javascript和jsp/servlet都有哪些通信方式?
- 简单问题!!如果想控制输入的文本只能是数字,怎么办?
- 有一个文本域,我想让它里边的字显示为粗体,通过点击"加粗"按钮来实现,应该怎样写?谢谢
- 怎么在服务器端编写javascript脚本?
- 如何使用Javascript控制双屏显示器的客户端???
- JS给checkbox赋值,后台取值的问题
- 【求教】关于Ajax success后填充select ui 插件问题!
- ckediter+ckfinder windows可以上传,lunix就是不行
但我在dreamweaver中这样写javascript代码有反应,可以弹出alert。
究竟什么问题啊~~~~~
然后
var str1= document.getElementById("input1").value;
不要用document.myform.1.value;
嗯。是这样的,还有个问题。就是
还有就是var str="StuServletst?uname=str1&stusno=str2&stuage=str3&stusex=str4&studept=str5";
send_request(str);//这里是传给ajax处理的
把表单中的数据传给ajax再传给服务器吗?
服务器servlet将收到的数据插入到数据库,由于编码不一样
插入到数据库显示:将截断字符串或二进制数据。
怎样设置编码,让servlet能正常插入。
var str2= document.getElementById("input2").value; //document.myform.2.value;
var str3= document.getElementById("input3").value; //document.myform.3.value;
var str4=document.getElementById("input4").value; //document.myform.4.value;
var str5=document.getElementById("input5").value; //document.myform.5.value;
var str="StuServletst?uname=str1&stusno=str2&stuage=str3&stusex=str4&studept=str5";
这里并没有把表单中的数据传过去,传过去的数据是stuuname=str1,......studept=str5;
那么该怎么写才能把表单中的数据提交过去呢?
但插入数据库是乱码,还要纠结下去,烦哦,问题多多,头都大了
但不知怎么设置让插入的中文数据不显示乱码?
response.setCharacterEncoding("UTF-8");如果你页面是 GBK 你就把 UTF-8 改为 GBK
我页面是gb2312编码的。在servlet中request.setCharacterEncoding("gb2312");
response.setCharacterEncoding("gb2312");
只是插入数据库中的中文数据是乱码
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("GBK");
response.setCharacterEncoding("GBK");
request.setCharacterEncoding("gb2312");
response.setCharacterEncoding("gb2312");
都不行啊????????
求解,求解,求解!!!!
gb2312 ,我如果直接用servlet向SQLserver插入数据就可以,但我要用ajax传来的数据就是乱码,好像是ajax的编码是UTF-8,我不晓得怎么转换啊?????