繁体   English   中英

根据单选按钮显示/隐藏表格行

[英]Show / Hide table row based on radio buttons

我有一组四个单选按钮,分别代表四个不同的条件(好,改善,恶化,差)。 选择“变差”或“变差”应取消隐藏带有文本区域的表行,以说明条件不好的原因。 选择“好”或“改善”将隐藏表行。 我尝试将一个类添加到取消隐藏表行的两个类中,但是只有一个按钮在起作用(令人担忧)。 我感觉我需要在某处放置一个or子句来同时拾取两个按钮,但是我尝试了许多变体,但我只是没有想到。 感谢这个菜鸟的任何帮助。

这是我所拥有的:

<tr>
     <td>
      Customer Sentiment:
    </td>
    <td colspan="3">
    <div id="sentiment">
        <input class="xhide" type="radio" id="Good" value="1"   name="sentimentID" <cfif sentimentID eq 1>checked</cfif> /><label for="Good">Good</label>
        <input class="xhide" type="radio" id="Improving" value="2" name="sentimentID" <cfif sentimentID eq 2>checked</cfif> /><label for="Improving">Improving</label>
        <input class="xshow" type="radio" id="Worsening" value="3" name="sentimentID" <cfif sentimentID eq 3>checked</cfif> /><label for="Worsening">Worsening</label>
        <input class="xshow" type="radio" id="Poor" value="4"   name="sentimentID" <cfif sentimentID eq 4>checked</cfif> /><label for="Poor">Poor</label>
    </div>
    </td>
</tr>                        

<tr class="rnotes"">
    <td valign="top">Sentiment Notes:</td>
    <td colspan="3">
        <cfoutput>
        <textarea   name="sentimentNotes"
                    cols="100"
                    rows="4">#sentimentNotes#</textarea>
        </cfoutput>
    </td>
</tr>

脚本:

$(document).ready(function() 
{
    $(".rnotes").hide();

    $(':radio').change(function(){
    var isChecked=$('.xshow').prop('checked');
    $('.rnotes').toggle(isChecked);
    });
});

================================================== ======================

这是脚本:

$(document).ready(function() 
{
    $(".rnotes").hide();

    $('input[type=radio]').change(function(){
        var isChecked = $(this).prop('checked');
        var isShow = $(this).hasClass('xshow');
        $(".rnotes").toggle(isChecked && isShow);
    });
});

工作提琴: http : //jsfiddle.net/LnyJZ/5/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM