我正在尝试设置一个文本框,如果"其他"复选框已选中
这是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('ctl00_ContentPlaceHolder1_pageControl_eligibility1_other')" onblur="ASPx.ELostFocus('ctl00_ContentPlaceHolder1_pageControl_eligibility1_other')" onchange="ASPx.EValueChanged('ctl00_ContentPlaceHolder1_pageControl_eligibility1_other')" 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>
请帮我在我的javascript中找到错误。它不允许我更详细地保存我的更改,因为这个问题主要是代码...
答案 0 :(得分:0)
以下是我的问题的答案: function selectedIndexChanged(s,e){ var item = reasons.GetSelectedItem(); if(item.text ==&#39; Other&#39;){ txtBoxOther.SetVisible(真);