关于javascript全局变量和局部变量访问的问题!! 本帖最后由 mqslll594212 于 2012-07-10 17:44:37 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在赋值v1的时候dom还未加载,所以document.getElementById("number1")是取不到值的。 <html><head><script language="javascript">var pub = "全局变量"var v1;function sayHello(){v1 = parseInt(document.getElementById("number1").value); alert("pub是" + pub + ",可以提示出来。");}function test(){//v1 = parseInt(document.getElementById("number1").value) ;alert(v1);alert("v1也是全局变量,但是总提示没有定义。");} </script></head><!-- 在页面载入时执行 --><body onload="sayHello()"><input type = 'text' name = 'number1' id = 'number1'><p><input type = 'button' name = 'button' id = 'button' value ='显示' onclick = "test()"></body></html> 多谢!!<html><head><script language="javascript">var pub = "全局变量"var v1;function sayHello(){v1 = parseInt(document.getElementById("number1").value); alert("pub是" + pub + ",可以提示出来。");alert(v1);}function test(){v1 = parseInt(document.getElementById("number1").value) ;alert(v1);} </script></head><!-- 在页面载入时执行 --><body onload="sayHello()"><input type = 'text' name = 'number1' id = 'number1'><p><input type = 'button' name = 'button' id = 'button' value ='显示' onclick = "test()"></body></html> 看来得好好研究Dom和var赋值了。 总是出现java.lang.NullPointerException JQuery zTree 又见乱码问题 关于SQLException异常 关于使用分页标签 highcharts x轴相等,y轴上的多点数据显示 写了个hibernate简单程序,结果报这种错。谁知道原因? 有谁知道org.htmlparser.Parser是哪个API的类啊?[请大家帮忙查一下,谢谢大家了!] 再问简单问题!JSP方面的。 在hibernate中,用Middlegen-Hibernate来实现对数据库中表的映射的问题??? JSP中out输出问题 commons-io.1.1版本的疑问
<head>
<script language="javascript">
var pub = "全局变量"
var v1;
function sayHello(){
v1 = parseInt(document.getElementById("number1").value);
alert("pub是" + pub + ",可以提示出来。");
}function test(){
//v1 = parseInt(document.getElementById("number1").value) ;
alert(v1);
alert("v1也是全局变量,但是总提示没有定义。");
}
</script>
</head>
<!-- 在页面载入时执行 -->
<body onload="sayHello()">
<input type = 'text' name = 'number1' id = 'number1'><p>
<input type = 'button' name = 'button' id = 'button' value ='显示' onclick = "test()">
</body>
</html>
<head>
<script language="javascript">
var pub = "全局变量"
var v1;
function sayHello(){
v1 = parseInt(document.getElementById("number1").value);
alert("pub是" + pub + ",可以提示出来。");
alert(v1);
}function test(){
v1 = parseInt(document.getElementById("number1").value) ;
alert(v1);
}
</script>
</head>
<!-- 在页面载入时执行 -->
<body onload="sayHello()">
<input type = 'text' name = 'number1' id = 'number1'><p>
<input type = 'button' name = 'button' id = 'button' value ='显示' onclick = "test()">
</body>
</html>