Asp:RadioButtonList SelectedIndex不改变时,设置javascript,然后按钮被禁用
Asp:RadioButtonList SelectedIndex not changing when set by javascript and then the buttons are disabled
我有一个asp:RadioButtonList有三个选择,其中第二个被设置为Selected = True,基于这三个选择,javascript显示/隐藏表的部分时,他们被选中。
这通常工作得很好,但在一个实例中,基于下拉列表选择,我将所选的单选按钮设置为第一个,然后禁用单选按钮,因为它们不能为该实例选择任何其他内容。
当我试图在保存时读取代码中的selectedIndex时,所选择的更改尚未被捕获,并且它返回第二个选择而不是第一个选择。
<asp:RadioButtonList ID="CheckFaktura" Width="100%" runat="server" CellPadding="10"
CellSpacing="10" RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem>Privat</asp:ListItem>
<asp:ListItem Selected="True">Bedrift</asp:ListItem>
<asp:ListItem>Fakturasentral</asp:ListItem>
</asp:RadioButtonList>
if (ddl.options[ddl.selectedIndex].value != "Er i jobb") {
document.getElementById("stilling").style.display = "none";
document.getElementById("Innmeldingfirmanavn").style.display = "none";
document.getElementById("Innmeldingorgnummer").style.display = "none";
document.getElementById("Innmeldingfirmaadresse").style.display = "none";
document.getElementById("Innmeldingfirmasted").style.display = "none";
document.getElementById("stillingsgruppe").style.display = "none";
document.getElementById("RequiredFieldValidatorFN1").enabled = false;
document.getElementById("RequiredFieldValidatorON1").enabled = false;
document.getElementById("RequiredFieldValidatorFA1").enabled = false;
document.getElementById("RequiredFieldValidatorFP1").enabled = false;
document.getElementById("RequiredFieldValidatorFS1").enabled = false;
document.getElementById("CheckFaktura_0").checked = true;
//document.getElementById("CheckFaktura").disabled = true;
$("#CheckFaktura").find('input').prop('disabled', true);
document.getElementById("rfvStillingsgruppe").enabled = false;
ShowHideFaktAdresse();
我假设是禁用把一切都搞砸了,但我需要另一种方法来确保用户不能选择其他选项。
edit: AutopostBack不是一个选项,因为它会扰乱页面上的其他内容。
让你的下拉列表和单选按钮列表自动返回,并在代码后面做你的工作,它会工作的。
我设法让它工作,除了一个必须被选中禁用的按钮。
没有解释为什么它不起作用,但至少如果其他人有同样的问题,这是一种可能的方法。
相关文章:
- Javascript运行php文件,然后下载文件
- 设置随机数,然后每5秒随机减少一次,直到达到0(javascript)
- 需要使用javascript获取输入文本,然后将其添加到句子中
- 显示数字,然后每5秒随机更改一次(javascript)
- javascript:发送带有音频文件的POST,然后重定向到新页面
- 如何利用多链接延迟检查并显示ping结果,然后使用JavaScript选择最快的URL
- 多个下载链接到一个zip文件,然后再下载javascript
- 如何用javascript调用函数,然后在滚动事件中调用该函数的特定实例
- 如何放置ÅÄ和#214;在javascript数组中,然后将其与html文本进行比较
- Javascript:将多个表打印成一行,然后再打印
- Javascript解析器本身是用类似ESPRIMA的Javascript编写的,这是如何工作的?然后谁解析ESPRIM
- 如何使用javascript验证表单中的数据,然后调用php页面
- Javascript onclick需要点击两次,然后会创建越来越多的服务器请求
- 椭圆字幕选择,然后在Photoshop中使用Javascript填充颜色
- Javascript重复模式匹配,然后输出到文本区域
- 使用JavaScript或AJAX从HTML表单中提取数据,然后将其传递给PHP
- JavaScript onclick在IE 9中工作两次,然后停止
- 如何获取XML值,然后使用javascript将它们输出到htm文件中
- 如何点击标题中的链接,然后返回HTML、Javascript和CSS
- HTML将参数传递给javascript函数,然后javascript函数进行日期比较,然后javascript返回以H