qq_16188625 2015-12-07 08:30 采纳率: 0%
浏览 2640

document.getElementById()获取的值不对

 <html>
<head>
<title>控制首页</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="css/table.css">
</head>
<script type="text/javascript">
    function checkState() {
        var bc_id = document.getElementById("bc_id").value;
        var bc_state = document.getElementById("bc_state").value;
        alert("bc_id======="+bc_id+"******************bc_state========"+bc_state);
        document.form1.action = 'AutoBatchConfig_updateAutoBatchState.action?bc_id='+bc_id+'&bc_state'+bc_state;
    }
</script>
<body>
    <center>
    <form action="" method="post" id="form1" name="form1">
        <div style="overflow-x: auto; overflow-y: auto; width: auto; height: 490px">
            <table cellspacing="0">
                <tr>
                    <td style="width:778px;">服 务 拨 测 控 制 台</td>
                </tr>
            </table>
            <table cellspacing="0">
                <tr style="text-align: center;">
                    <th scope="col" style="width:150px">序列</th>
                    <th scope="col" style="width:400px">控制项</th>
                    <th scope="col" style="width:200px">任务状态</th>
                </tr>
                <s:iterator value="#request.autoBatchConfigList" var="rel" status="st">
                    <tr>
                        <th scope="col" style="width:150px">
                            <s:property value="#rel.bc_id" />
                        </th>
                        <th scope="col" style="width:400px">
                            <s:property value="#rel.bc_name" />
                        </th>
                        <th scope="col" style="width:200px">
                            <s:if test="%{#rel.bc_state == \"1\"}">
                                <input type="image" src="images/stop.gif" onclick="checkState()" title="<s:property value="#rel.bc_id"/>"/>
                            </s:if> 
                            <s:else>
                                <input type="image" src="images/running.gif" onclick="checkState()" title="<s:property value="#rel.bc_id"/>"/>
                            </s:else>
                            <input type="text" id="bc_id" value="<s:property value="#rel.bc_id"/>" style="width:50px;"/> 
                            <input type="text" id="bc_state" value="<s:property value="#rel.bc_state"/>" style="width:50px;"/>
                        </th>
                    </tr>
                </s:iterator>
            </table>
        </div>
    </form>
    </center>
</body>

</html>

图片说明
点击序列“3”后的小红色图片
图片说明

结果应该是bc_id=3,bc_state=1才对

  • 写回答

6条回答 默认 最新

  • wang1hong2lu3 2015-12-07 09:02
    关注

    你好像有好多个id 是 bc_id的 你那个似乎是循环添加的吧 这样可能回产生很多个相同的id

    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置