问题描述
- javascrip 全局变量 使用时undefined
-
<%@ page language=""java"" contentType=""text/html; charset=utf-8"" pageEncoding=""utf-8""%><%@ taglib prefix=""c"" uri=""http://java.sun.com/jsp/jstl/core""%><html><head><meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8""><title>test</title><% String bnoname = request.getParameter(""bnoname""); String start = request.getParameter(""start""); String end = request.getParameter(""end"");%><script type=""text/javascript""> var chart option charts options; var oldname = """"; var bnoname = ""<%=bnoname%>""; var start = ""<%=start%>""; var end = ""<%=end%>""; $(document).ready(function() { selectBno(); updatedatas(); }); function updatedatas() { alert(bnoname); } function selectBno() { oldname = ""value1""; if(bnoname == ""null""){ bnoname = oldname; } } $(function() { $('#bookview').edatagrid({}); }); function initpolygon1detail(polygon) { charts = echarts.init(document.getElementById(polygon)); }</script></head><body style=""visibility: visible;"" ><div id=""polygondetail1"" style=""height:400px;width:95%; margin-top:30px; margin-left:20px;""></div> <div style=""width: 95%; margin-left:20px;""> <table id=""bookview"" title=""历史记录"" rownumbers=""true"" pagination=""true"" fitColumns=""true"" singleSelect=""true"" pageSize=10 width=100%/> </div> </body></html>
在updatedatas函数中弹出的对话框中,不是已经赋值的
解决方案
就是没有取得值,你看看参数是不是没有传递过来
解决方案二:
var chart option charts options; var oldname = """"; var bnoname = ""<%=bnoname%>""; var start = ""<%=start%>""; var end = ""<%=end%>"";这行写在js里面。
解决方案三:
if(bnoname == ""null"")说明你这句对比为false所以没执行赋值
如果你的bnoname是空字符要这样
if(bnoname == """"){
解决方案四:
肯定是没有取得值,参数应该没有过来,否则不会未定义...
时间: 2024-09-16 05:33:44