首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

JSP中写的javascript代码中的函数没反应,咋回事啊

2013-01-11 
JSP中写的javascript代码中的函数没反应,怎么回事啊?这是我的一个按钮onclick的函数:function addstu(){va

JSP中写的javascript代码中的函数没反应,怎么回事啊?
  这是我的一个按钮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再传给服务器吗?
初学这些,还是在自学的,老师都没讲,喊我们用这做课程设计。遇到很多问题啊~~~烦~哪位大侠能解决下,万分感谢!
[解决办法]
首先的命名就不合法, 以必须以字母开头,
然后
var str1= document.getElementById("input1").value;
不要用document.myform.1.value;
[解决办法]
你的Q是多少,我的:1302006889

热点排行