日期:2014-05-17  浏览次数:20643 次

jsp调用jsp中的方法
<%!
String Name=null;
%>
<%!
String Pwd=null;
%>
String NameAndPWD(String Name,String Pwd){
if (Name.trim().equals("")||Pwd.trim().equals("")){
return "用户名或密码不能为空!";
}
else{
return "";
}
}
此方法用于判断登录名密码是否有为空情况
通过<input type="submit" value="Login" style="width:100px;height:25px" onclick="<%=Name %>=form1.name.value"/> 给定义的变量赋值
如何传递参数 如何将值赋给 控件的value属性

如果有更好的方法请不吝赐教 新手求鞭挞




------解决方案--------------------
楼主可是这个意思?在A.js中读取B.js的变量?
在A中加载B,然后把B中要读取的变量定义为全局变量就OK了



<html>
<head>
<script src=A.js type="text/javascript"></script>
</head>
  <body onLoad = test()>
  </body>
</html>



A.js里加入

var head = document.getElementsByTagName('head');

var exampleScript = document.createElement('script');
exampleScript.src = 'B.js';
exampleScript.type = 'text/javascript';
head[0].appendChild(exampleScript);

function test(){
     document.writeln(num);
}


B.js

var num=12345;