日期:2014-05-20  浏览次数:20663 次

checkbox 的 onclick 不能调用javascript里面定义的函数
先说一下,我是想但选择checkbox的时候,调用javascript里面定义的函数
但是却不能进入函数
而我在onclick上面添加alert的时候却是可以响应的
这是为什么,麻烦各位高手们指点下!谢谢
代码如下:

<%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>
<%@include file="/common/common.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language="javascript" src="script/public.js"></script>
<link href="style/oa.css" rel="stylesheet" type="text/css">
<title>授权管理</title>
</head>
<script type="text/javascript" language="javascript">
  var XMLHttpReq;

  //创建XMLHttpRequest对象  
  function createXMLHttpRequest() {
  if(window.XMLHttpRequest) { //Mozilla 浏览器
  XMLHttpReq = new XMLHttpRequest();
  }
  else if (window.ActiveXObject) { // IE浏览器
  try {
  XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
  } catch(e){
  try {
  XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e) {}
  }
  }
  }

  //发送请求函数
  function addOrUpdatePermission(var field) {
  alert("hi"); //没有执行到这里
  createXMLHttpRequest();
  var url = "acl.do?method=addOrUpdatePermission&moduleId=" + field.moduleId + "&permission=" + field.permission + "&authorizationTypeId=" + field.authorizationTypeId + "&authorizationType=" + field.authorizationType;
  // 加随机数防止缓存
if (url.indexOf("?") > 0)
{
url += "&randnum=" + Math.random();
}
else
{
url += "?randnum=" + Math.random();
}
// 设定请求编码方式
  setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
  XMLHttpReq.open("GET", url, true);
  XMLHttpReq.onreadystatechange = processResponse;//指定响应函数
  XMLHttpReq.send(null); // 发送请求
  }

  // 处理返回信息函数
  function processResponse() {
  if (XMLHttpReq.readyState == 4) { // 判断对象状态
  if (XMLHttpReq.status == 200) { // 信息已经成功返回,开始处理信息
  alert("添加了");
  DisplayHot();
  //setTimeout("sendRequest()", 1000);
  } else { //页面不正常
  window.alert("您所请求的页面有异常。");
  }
  }
  }

  // 显示更新数据信息的函数___
  function DisplayHot(){
  }
   
  function hello(){
  alert("hi");
  }
</script>
<body>
<div align="center"><br>
<c:if test="${aclForm.authorizationType eq 'User'}">
  <font size="4" >请给用户[<font color="red">${person.name }</font>]授权</font>
  </c:if>
  <c:if test="${aclForm.authorizationType eq 'Role'}">
  <font size="4" >请给角色[<font color="red">${role.name }</font>]授权</font>