我有两个radio,下面有动态增加行内容的一个表格。
我想做的效果是:当我选中其中一个的时候,只显示跟这个radio有关的内容,应该怎么弄?

解决方案 »

  1.   

    onClick = "alert(this.value)"
      

  2.   


    忘了贴了:
    <input type="radio" id="kind0" name="kind" value="0" />
    收入
    <input type="radio" id="kind1" name="kind" value="1" />
    支出
    <table bgcolor="#eeeeff" width="60%" border="1">
    <tr>
    <th width="15%">
    序号
    </th>
    <th width="20%">
    收支类型
    </th>
    <th width="25%">
    类型名称
    </th>
    <th width="30%">
    备注
    </th>
    <th width="10%">
    &nbsp;
    </th>
    </tr> <c:forEach items="${type}" var="item" varStatus="s">
    <tr class="kind${item.kind }">
    <td width="15%" align="center">
    ${s.count}
    </td>
    <td width="20%" align="center">
    <c:choose>
    <c:when test="${item.kind==0}">
    收入
    </c:when>
    <c:otherwise>
    支出
    </c:otherwise>
    </c:choose>
    </td>
    <td width="25%" align="center">
    ${item.typeName}
    </td>
    <td width="30%" align="center">
    <c:choose>
    <c:when test="${empty item.re}">

    </c:when>
    <c:otherwise>
    ${item.re }
    </c:otherwise>
    </c:choose>
    </td>
    <td width="10%" align="center">
    <a href="deleteType?id=${item.typeId }"
    onclick="return confirm('确定删除?')">删除</a>
    </td>
    </tr>
    </c:forEach> </table>再帮我看看
      

  3.   

                <input type="radio" id="kind0" name="kind" value="0" onclick="document.forms[0].submit();" />
                收入
                <input type="radio" id="kind1" name="kind" value="1" onclick="document.forms[0].submit(); />
                支出
                <table bgcolor="#eeeeff" width="60%" border="1">
      

  4.   


    这容易啊,加两个<span>:
    <script>
    function aaa(n){
      var o1=document.getElementsByName(''cainiao0);
      var o2=document.getElementsByName(''cainiao1);
     
      o1.style.display=n==0?"":"none";
      o2.style.display=n==0?"none":"";
    }
    </script>
    <input type="radio" id="kind0" name="kind" value="0" onclick="aaa(this.value);" />收入
    <input type="radio" id="kind1" name="kind" value="1" onclick="aaa(this.value);" />支出
    。 
    <tr><td><span name='cainiao0' style="display:''"></span><span name='cainiao1' style="display:'none'"></span></td></tr>
    ............
      

  5.   

    或者,也可以在window.onload()里AJAX回来全部数据,组成JSON,再写到相应的<td></td>里。加上刷新,三种方法都可以