<head>
</head>
<script type="text/javascript" charset="utf-8">
function sv(chb,str)
{
if(chb.checked==true)
{
document.forms["GSgrglmf"].item("xz").value=str;
alert(document.forms["GSgrglmf"].item("xz").value);
}
}
</script>
<body>
……
</body>
<form name="GSgrglmf" method="post" action="server.do?action=j21" >
……
<td><input name="xz" type="checkbox" id="sfzx" value="checkbox" onClick="sv(document.forms['GSgrglmf'].item('xz'),'<%=r_i.getZzhm()%>')">选择</td>
……
</form>用ie8总提示onClick="sv(document.forms['GSgrglmf'].item('xz'),'<%=r_i.getZzhm()%>')这一段缺少对象。

解决方案 »

  1.   

    <%=r_i.getZzhm()%>这个是什么??
      

  2.   

    都改成这样写试试document.GSgrglmf.xz
      

  3.   

    应该是 document.forms['GSgrglmf'].item('xz')没有找到对象
      

  4.   

    <form name="GSgrglmf" method="post" action="server.do?action=j21" >
     改成<form id="GSgrglmf" method="post" action="server.do?action=j21" >或者加一个id属性=“GSgrglmf”
      

  5.   

    那你试试document.getElementById("xz").value
      

  6.   


    jsp代码 调用一个对象的方法
      

  7.   

    为什么不用this?这么折腾。onClick="sv(this,' <%=r_i.getZzhm()%>')
      

  8.   

    代码应该没有问题.
    请你先确认下
    <script type="text/javascript" charset="utf-8">
    function sv(chb,str)
    {
        if(chb.checked==true)
        {
            document.forms["GSgrglmf"].item("xz").value=str;
            alert(document.forms["GSgrglmf"].item("xz").value);
        }
    }
    </script>
    这里<script type="text/javascript" charset="utf-8"></script>中的代码没有问题,如果有问题的话,会导致加载sv(chb,str)失败,从而找不到这个方法。
    如果不是方法找不到的话,那么请尝试
    onClick="sv(document.forms['GSgrglmf'].item('xz'),' <%=r_i.getZzhm()%>') 改成
    onClick="sv(this,' <%=r_i.getZzhm()%>')