0

そのため、リストボックスの選択に基づいてコンテンツを非表示および表示しようとしています。ページの読み込み時にcssを使用して一部のコンテンツを非表示にし、特定のものが選択されたときに表示します。ほとんどは機能しますが、これらのラジオ ボタンが表示されない理由がわかりません。

ここにラジオボタンとラベルがあります...

        <br /><!--View/Send By-->
        <asp:Label ID="lblViewSend" runat="server" Text="View/Send as" style="display:none;"></asp:Label>
        <asp:RadioButton ID="rdViewPrint" Text="View/Print" runat="server" OnClick="javascript:disableFields();" GroupName="viewSend" Checked="True" style="display:none; margin-left:10px;" />
        <asp:RadioButton ID="rdEmail" Text="Email" runat="server" OnClick="javascript:emailFields();" GroupName="viewSend" style="display:none; margin-left:10px;" />
        <asp:RadioButton ID="rdFax" Text="Fax" runat="server" OnClick="javascript:faxFields();" GroupName="viewSend" style="display:none; margin-left:10px;" />

リストボックスでアイテムが選択されたときにそれらを表示するJavaScript...

function lbSelected() {
             var sel = document.getElementById('<%=lbPatientVisits.ClientID%>');
             var listlength = sel.options.length;

             document.getElementById('<%=lblViewSend.ClientID%>').style.display = "inherit";
             document.getElementById('<%=rdViewPrint.ClientID%>').style.display = "inherit";
             document.getElementById('<%=rdEmail.ClientID%>').style.display = "inherit";
             document.getElementById('<%=rdFax.ClientID%>').style.display = "inherit";
//...plus more code that functions correctly...
    }

ラベルはページに表示されるはずですが、ラジオ ボタンは表示されません。私もこれを少しバリエーションとして試しましたが、この方法でも機能しませんでした...

var rbtn = document.getElementById('<%=rdViewPrint.ClientID%>');
         rbtn.style.display = 'inherit';

何が欠けているか、または見落としていますか? コードは通常のボタンとラベルでは正常に機能するようですが、ラジオ ボックスでは機能しませんか? 助けてくれてありがとう。

4

1 に答える 1

0

これは、jquery を使用した完全な例です。

<script type="text/javascript" src="Scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("#name").click(function () {
            $("#<%=this.myRadio.ClientID %>").toggle();
        });
    });
</script>


    <asp:RadioButtonList runat="server" ID="myRadio">
        <asp:ListItem Text="text1" />
        <asp:ListItem Text="text2" />
    </asp:RadioButtonList>
    <input type="button" id="name" value="click me" />
于 2012-07-02T21:34:29.100 に答える