How to pass an anonymous array of strings to a JavaScript function?
        Posted  
        
            by abatishchev
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by abatishchev
        
        
        
        Published on 2010-04-05T17:48:01Z
        Indexed on 
            2010/04/05
            17:53 UTC
        
        
        Read the original article
        Hit count: 201
        
I want to pass to an array of controls' IDs to a javascript script function so it will switch control's enable state.
For example, in C# it would be like this:
func(false, new[] { "Control1", "Control2", "Control3" });
In that function I want to find corresponding controls and disable/enable them. For one control I do this next way:
<script type="text/javascript" language="javascript">
    function switchControls(value, arr) {
        for (var n = 0; n < array.length; n++)
            document.getElementById(n).disabled = value;
    }
</script>
<asp:CheckBox runat="server"
     onclick="switchControls(this.checked,
        [
            '<%= Control1.ClientID %>',
            '<%= Control2.ClientID %>'
        ])" 
     Text="Take?" />
How to implement this properly? Have I to use jQuery?
© Stack Overflow or respective owner