2

I have two ImageButtons on my page. Upon clicking one, I want to hide it and display the other. My current code is:

var button_mute = document.getElementsByID("ImageButtonMute");
var button_unmute = document.getElementsByID("ImageButtonUnmute");

    function mute() {
        vid_left.mute();
        vid_right.mute();

        button_mute.style.display = "block";
        button_unmute.style.display = "none";
    }

    function unmute() {
        vid_left.unMute();
        vid_right.unMute();

        button_mute.style.display = "none";
        button_unmute.style.display = "block";
    }


<asp:ImageButton ID="ImageButtonMute" runat="server" 
        ImageUrl="~/icons/volume_mute_small.png" OnClientClick="mute()" />
    <asp:ImageButton ID="ImageButtonUnmute" runat="server" 
        ImageUrl="~/icons/volume_unmute_small.png" OnClientClick="unmute()" />

I haven't referenced either in the code behind, and I'm not sure why this isn't working. Any help is appreciated, thanks.

2
  • Did you put the javascript in a <script> tag? Commented Apr 9, 2012 at 23:34
  • document.getElementsByID != document.getElementByID Commented Apr 9, 2012 at 23:43

1 Answer 1

2

Use this select:

var button_mute = document.getElementsByID('<%= ImageButtonMute.ClientID %>');
var button_unmute = document.getElementsByID('<%= ImageButtonUnmute.ClientID %>');

This should work!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.