asp.net javascript radiobuttonlist索引确定另一个radiobuttonlist索引 [英] asp.net javascript radiobuttonlist index determine another radiobuttonlist index

查看:67
本文介绍了asp.net javascript radiobuttonlist索引确定另一个radiobuttonlist索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要让javascript根据另一个dropdownlist的所选索引来更改drowndownlist所选索引.无法使用面板更新,因为最终会有多个下拉列表受到影响.有人告诉我我做错了吗?

I need to have javascript change a drowndownlist selected index based on another dropdownlist''s selected index. Can''t use panel updates because I''ll have mulitple dropdownlist affected eventually. Anybody tell me what I''m doing wrong?

<pre lang="xml"><head runat="server">

        <script language="javascript"  type="text/javascript">
            // For changing sessions
        function getSessions() {
            if (document.getElementById("radF").selectedIndex == 2) {
                (document.getElementById("radP").selectedIndex == 1);
            }
        }
        </script>

<body>
    <form id="form1" name="form1" runat="server" enableviewstate="true"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>



    <asp:RadioButtonList id="radP" runat="server" RepeatColumns="2" RepeatDirection="vertical" >
                    <asp:ListItem Text="one" value="one" />
                    <asp:ListItem Text="two" value="two" />
                    <asp:ListItem Text="three" value="three" />
                    </asp:RadioButtonList>

                    <asp:RadioButtonList id="radF" runat="server" RepeatColumns="2" RepeatDirection="vertical"  onChange="javascript:getSessions(this.form);" >
                    <asp:ListItem Text="one" value="one" />
                    <asp:ListItem Text="two" value="two" />
                    <asp:ListItem Text="three" value="three" />
                    </asp:RadioButtonList>


推荐答案

仍然没有它-当我查看呈现的代码时,我意识到复选框被呈现为表格并将列表项作为带有输入标签的单个复选框.因此,我正在尝试一种新的方法,但是却一无所获.有帮助吗?

Still don''t have it - I realized when I looked at the rendered code, the checkboxlist is rendered as a table and the listitems as individual checkboxes with input tags. So, I''m trying a new way but not getting anywhere. Any help?

function getSessions() {
    var CHK = document.getElementByName(''radF'');
    var checkbox = CHK.getElementsByTagName(''input'');
    var CHK2 = document.getElementByName(''radP'');
    var checkbox2 = CHK2.getElementByTagName(''input'');

    for (var i = 0; i < checkbox.length; i++) {
        if (checkbox[i].checked) {
            if (checkbox[i].value = ''three'') {
                for (var2 = j = 0; j < checkbox2.length; i++) {
                    if (j = 2) {
                        checkbox2.selectedIndex = j
                    }
                }
            }
        }
    }
}


这篇关于asp.net javascript radiobuttonlist索引确定另一个radiobuttonlist索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆