Having a checkbox make something available when it's checked.

Discussion in 'ASP .Net Web Controls' started by Mufasa, Mar 25, 2008.

  1. Mufasa

    Mufasa Guest

    I have a check box with javascript code attached to it that will allow me to
    enable an 'accept' butten when the person has checked the box. The code is:

    input type="checkbox" name="checkbox"
    onclick="javascript:document.getElementById('ctl00$MainPage$btnToCheckout').disabled=!this.checked;
    return true; " />I


    The code works fine in IE - the button becomes enabled when the check box is
    clicked. But if Firefox it doesn't work.

    Any thoughts?

    TIA - Jeff.
    Mufasa, Mar 25, 2008
    #1
    1. Advertising

  2. Mufasa

    Mufasa Guest

    That works fine except that I'm using an ASP:Button with code behind it.
    That's why the funny name.

    Any thoughts on getting this to work with ASP controls?

    TIA - Jeff.

    "David R. Longnecker" <> wrote in message
    news:...
    > Jeff-
    >
    > The Ctl00$... isn't necessary (as far as I know) on either of the
    > browsers; that's the control hierarchy generated by .NET. getElementById
    > should be able to find the control simply by it's Id attribute.
    >
    > <div>
    > <input type="checkbox"
    > onclick="javascript:document.getElementById('btnToCheckOut').disabled=!this.checked;
    > return true;" />Accept?
    > <button id="btnToCheckOut" disabled="disabled">Checkout</button>
    > </div>
    >
    > Tested in FF2, IE7, and Safari and works just fine.
    >
    > HTH.
    >
    > -dl
    >
    > --
    > David R. Longnecker
    > http://blog.tiredstudent.com
    >
    >> I have a check box with javascript code attached to it that will allow
    >> me to enable an 'accept' butten when the person has checked the box.
    >> The code is:
    >>
    >> input type="checkbox" name="checkbox"
    >> onclick="javascript:document.getElementById('ctl00$MainPage$btnToCheck
    >> out').disabled=!this.checked; return true; " />I
    >>
    >> The code works fine in IE - the button becomes enabled when the check
    >> box is clicked. But if Firefox it doesn't work.
    >>
    >> Any thoughts?
    >>
    >> TIA - Jeff.
    >>

    >
    >
    Mufasa, Mar 26, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthew Louden

    checkbox checked change event question

    Matthew Louden, Nov 18, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    5,377
    Teemu Keiski
    Nov 18, 2003
  2. RodBillett

    Always One checkbox checked

    RodBillett, Dec 4, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    1,236
    bruce barker
    Dec 4, 2003
  3. yurps
    Replies:
    1
    Views:
    6,860
    rajeshthangarasu1983
    Feb 29, 2008
  4. randy
    Replies:
    13
    Views:
    427
    Tad McClellan
    Nov 1, 2003
  5. AFN
    Replies:
    6
    Views:
    133
    Dr John Stockton
    Jan 17, 2005
Loading...

Share This Page