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函数中弹出的对话框中,不是已经赋值的

4个回答

就是没有取得值,你看看参数是不是没有传递过来

var chart, option, charts, options; var oldname = ""; var bnoname = "<%=bnoname%>"; var start = "<%=start%>"; var end = "<%=end%>";这行写在js里面。

if(bnoname == "null")说明你这句对比为false所以没执行赋值

如果你的bnoname是空字符要这样
if(bnoname == ""){

肯定是没有取得值,参数应该没有过来,否则不会未定义...

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐