大家好,我现在想实现在后台将一些数据显示在界面上,然后用户自己选择需要的选项对其进行操作。我现在的问题是如何实现在界面显示的内容,根据后台传过来的条件,比如后台传过来的标志位如果是FALSE时,在界面上实现该行所有内容变成灰色(该行使用了许多个TD,表示不同的信息,但想遇到标记位时,使该行所有的信息都为灰色,不可选的状态),并且使得该行的checkbox选项不可用,但对于其他标记位为TRUE的行,checkbox是可选的!谢谢!

解决方案 »

  1.   

    直接判断,如果是false,checkbox加一个disabled="disabled"属性,如果是true则无需加那个属性。
      

  2.   

    请问如何判断呢,我的数据和标记都是从后台传过来的,我写一些代码,大家看看帮我改一下,我刚接触javascript,还很不熟悉。
    我准备在snmpcards中添加一个标记flag,当值为TRUE时,checkbox可选,当为FALSE时,不可选。请大家帮我看看该咋对checkbox进行判断,谢谢
                <logic:notEmpty name="configForm" property="snmpcards">
                <%int i=0;%>
                <logic:iterate id="snmpcard" name="configForm" property="snmpcards">
                  <%
                    if (i%2==0) 
                      out.println("<tr bgcolor=\"F5F7FA\"> ");
                    else
                      out.println("<tr bgcolor=\"E8F2FE\"> ");
                  %> 
                  <td width="10%" align="center"> 
                    <html:checkbox property="keys" value="<%= "" + i %>" ></html:checkbox>
                  </td>
                  <td width="15%" align="center">
                  <div class="table-text-normal"><input type="text" name="snmpName" style="WIDTH: 75%" value="<bean:write name="snmpcard" property="deviceName"/>"></div></td>
                  <td width="15%">
                  <div class="table-text-normal"><bean:write name="snmpcard" property="deviceType"/></div></td>
                  <td width="15%" align="center">
                  <a href="http://<bean:write name="snmpcard" property="ip"/>" class="link-text" target="_blank"><bean:write name="snmpcard" property="deviceIP"/></a></td>
                    <td width="15%">
                  <div class="table-text-normal"><bean:write name="snmpcard" property="devicePosition"/></div></td>
                    <td width="15%">
                  <div class="table-text-normal"><bean:write name="snmpcard" property="deviceTypeEdition"/></div></td>
                   <td width="15%">
                  <div class="table-text-normal"><bean:write name="snmpcard" property="deviceID"/></div></td>
                  </tr>
                <% i++; %>
                </logic:iterate>
                </logic:notEmpty>
      

  3.   

    那个VALUE是什么值呢。是不是保存之前是否选中的状态的?
      

  4.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>价格</title>
    <link href="Library/default.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="jquery.js"></script>
    <script language="javascript">
    $(function(){
    $(".Price").click(function(){
    $(this).select();
    })
    $(".Price").bind("keyup",function(){
    // alert("1")
    var c =  $(".checkbox:checked")
    //c.attr("checked",false)
    // var t = $(".checkbox[checked=true]").parent();
     c.prev(".Price").val($(this).val());
    })
    $(".act").bind("click",function(){
     var c = $(this).prev(".checkbox");
     c.attr("checked",!c.attr("checked"))
    })
    })
    </script>
    </head>
    <body>
    <table id="price">
      <form id="formprice" name="formprice" method="post" action="setShardPrice.asp">
        <tr>
          <td><input type='text' name='Price' class='Price' value = '0' size='5' />
            |
            <input type='checkbox' name='checkbox' class = 'checkbox' />
            <input type='button' value='复选' class='act' /></td>
        <tr>
          <td><input type='text' name='Price' class='Price' value = '0' size='5' />
            |
            <input type='checkbox' name='checkbox' class = 'checkbox' />
            <input type='button' value='复选' class='act' /></td>
        <tr>
          <td><input type='text' name='Price' class='Price' value = '0' size='5' />
            |
            <input type='checkbox' name='checkbox' class = 'checkbox' />
            <input type='button' value='复选' class='act' /></td>
      </form>
    </table>
    </body>
    </html>
    下载jquery.js 
    在同一目录下,新建HTML页面,复制代码
    所有被选中的行,都会一起修改<input type='text' name='Price' class='Price' value = '0' size='5' />的值
    我想这是你事的.