Javascript 设置一个文本框,如果;其他";选中复选框

Javascript 设置一个文本框,如果;其他";选中复选框,javascript,Javascript,如果选中“其他”复选框,我将尝试设置一个可见的文本框 以下是HTML输出: <dx:ASPxCheckBoxList ID="reasons" ClientInstanceName="reasons" runat="server" ClientVisible="false"> <Items> <dx:ListEditItem Text="Location" Value="7" /> <dx:ListEditItem Text="

如果选中“其他”复选框,我将尝试设置一个可见的文本框

以下是HTML输出:

 <dx:ASPxCheckBoxList ID="reasons" ClientInstanceName="reasons" runat="server" ClientVisible="false">
    <Items>
    <dx:ListEditItem Text="Location" Value="7" />
    <dx:ListEditItem Text="Other" Value="8" />
    </Items>
    <ClientSideEvents SelectedIndexChanged="function(s, e){ if (reasons.getText()=='Other'){ txtBoxOther.SetVisible(true);}}" />
 </dx:ASPxCheckBoxList>
<br />


请解释为什么我的javascript代码不正确

    h2>Eligibility</h2>

    <input type="hidden" name="ctl00$ContentPlaceHolder1$pageControl$eligibility1$hdnID" id="ctl00_ContentPlaceHolder1_pageControl_eligibility1_hdnID" value="0" />



    <table class="dxeCheckBoxList_Material" id="ctl00_ContentPlaceHolder1_pageControl_eligibility1_reasons" style="border-collapse:separate;">
                        <tr>
                            <td class="dxe"><input id="ctl00_ContentPlaceHolder1_pageControl_eligibility1_reasons_VI" type="hidden" name="ctl00$ContentPlaceHolder1$pageControl$eligibility1$reasons" /><table>
                                <tr>
                                    <td><table class="dxeBase_Material dxeTAR" id="ctl00_ContentPlaceHolder1_pageControl_eligibility1_reasons_RB0">
                                        <tr>
                                            <td class="dxichCellSys"><span class="dxWeb_edtCheckBoxUnchecked_Material dxICheckBox_Material dxichSys"><span class="dxKBSW"><input id="ctl00_ContentPlaceHolder1_pageControl_eligibility1_reasons_RB0_I" name="ctl00$ContentPlaceHolder1$pageControl$eligibility1$reasons$RB0" value="I" type="text" readonly="readonly" style="opacity:0;width:0;height:0;position:relative;background-color:transparent;display:block;margin:0;padding:0;border-width:0;" /></span>       </span></td><td class="dxichTextCellSys"><label class="dx-wrap">Location</label>    </td>
                                        </tr>
                                    </table><script id="dxss_1836432940" type="text/javascript">
    <!--
ASPx.AddDisabledItems('ctl00_ContentPlaceHolder1_pageControl_eligibility1_reasons_RB0',[[[''],[''],['']]]);

    //-->
    </script></td>
                                </tr><tr>
                                    <td><table class="dxeBase_Material dxeTAR" id="ctl00_ContentPlaceHolder1_pageControl_eligibility1_reasons_RB1">
                                        <tr>
                                            <td class="dxichCellSys"><<input id="ctl00_ContentPlaceHolder1_pageControl_eligibility1_reasons_RB1_I" name="ctl00$ContentPlaceHolder1$pageControl$eligibility1$reasons$RB1" value="I" type="text" readonly="readonly" style="opacity:0;width:0;height:0;position:relative;background-color:transparent;display:block;margin:0;padding:0;border-width:0;" /></span>      </span></td><td class="dxichTextCellSys"><label class="dx-wrap">Other</label>   </td>
                                         </tr>
                                     </table><script id="dxss_1704498575" type="text/javascript">
     <!--
ASPx.AddDisabledItems('ctl00_ContentPlaceHolder1_pageControl_eligibility1_reasons_RB1',[[[''],[''],['']]]);

     //-->
     </script></td>
                                </tr>
                            </table></td>
                         </tr>
                      </table><script id="dxss_1417929759" type="text/javascript">
     <!--
    ASPx.AddDisabledItems('ctl00_ContentPlaceHolder1_pageControl_eligibility1_reasons',[[['dxeDisabled_Material'],[''],['','RB0','RB1']]]);

var dxo = new ASPxClientCheckBoxList('ctl00_ContentPlaceHolder1_pageControl_eligibility1_reasons');
dxo.InitGlobalVariable('reasons');
dxo.SetProperties({
    'uniqueID':'ctl00$ContentPlaceHolder1$pageControl$eligibility1$reasons',
    'imageProperties':{
    '4':['dxWeb_edtCheckBoxChecked_Material','dxWeb_edtCheckBoxUnchecked_Material'],
    '8':['dxWeb_edtCheckBoxCheckedDisabled_Material','dxWeb_edtCheckBoxUncheckedDisabled_Material']
},
    'icbFocusedStyle':['dxICBFocused_Material',''],
    'initSelectedIndices':[]
});
dxo.SetEvents({
    'SelectedIndexChanged':function(s, e){ if (reasons.getText()=='Other'){ txtBoxOther.SetVisible(true);}}
});
dxo.InitializeProperties({
    'decorationStyles':[
        {'key':'F','className':'dxeFocused_Material','cssText':''}
    ],
    'items':[['Location','7',''],['Other','8','']]
});
dxo.AfterCreate();

//-->
</script>
<br />
<table>
                    <tr>
                        <td class="dxic" style="width:100%;"><input class="dxeEditArea_Material dxeEditAreaSys" id="ctl00_ContentPlaceHolder1_pageControl_eligibility1_other_I" name="ctl00$ContentPlaceHolder1$pageControl$eligibility1$other" onfocus="ASPx.EGotFocus(&#39;ctl00_ContentPlaceHolder1_pageControl_eligibility1_other&#39;)" onblur="ASPx.ELostFocus(&#39;ctl00_ContentPlaceHolder1_pageControl_eligibility1_other&#39;)" onchange="ASPx.EValueChanged(&#39;ctl00_ContentPlaceHolder1_pageControl_eligibility1_other&#39;)" value="Enter Reason" type="text" /></td>
                    </tr>
                </table><script id="dxss_1988614690" type="text/javascript">
<!--
ASPx.AddDisabledItems('ctl00_ContentPlaceHolder1_pageControl_eligibility1_other',[[['dxeDisabled_Material'],[''],['','I']]]);

var dxo = new ASPxClientTextBox('ctl00_ContentPlaceHolder1_pageControl_eligibility1_other');
dxo.InitGlobalVariable('txtBoxOther');

    ]
});
dxo.AfterCreate();

//-->
</script>
h2>资格
地方


请帮助我找到javascript中的错误。它不允许我保存更改而不提供更多详细信息,因为这个问题主要是代码…

以下是我问题的答案: 所选函数索引已更改(s、e){ var item=reasons.GetSelectedItem(); 如果(item.text==“其他”){
txtBoxOther.SetVisible(true);

显示输出html而不是asp代码使用asp标记它或将其更改为html。请显示一些html并描述遇到问题的地方。请阅读如何在堆栈溢出中发布问题。请阅读此文以获得关于一个好问题的指导。以下是有关SE如何工作的示例