Required user to read - then click a checkbox and then a button becomes enabled.

Discussion in 'ASP .Net' started by Mufasa, Aug 31, 2007.

  1. Mufasa

    Mufasa Guest

    I have a screen where the user has to agree to stuff. I want them to have to
    click a check box saying they have read it and then have the ok button
    become available.

    What's the easiest way to do this?

    TIA - Jeff.
     
    Mufasa, Aug 31, 2007
    #1
    1. Advertising

  2. On Aug 31, 8:36 pm, "Mufasa" <> wrote:
    > I have a screen where the user has to agree to stuff. I want them to have to
    > click a check box saying they have read it and then have the ok button
    > become available.
    >
    > What's the easiest way to do this?
    >
    > TIA - Jeff.


    <input type="checkbox" name="checkbox" value="I have read the text
    above"
    onClick="javascript:document.getElementById('Button1').disabled=!
    this.checked;" />

    <asp:Button ID="Button1" runat=server Text="Submit"/>

    <script language="javascript">
    document.getElementById('Button1').disabled = true;
    </script>
     
    Alexey Smirnov, Aug 31, 2007
    #2
    1. Advertising

  3. On Aug 31, 9:11 pm, "Mufasa" <> wrote:
    > Thanks but that doesn't work. When I click on the checkbox, it tells me it
    > can't find the object Button1.
    > If you look at the source, there is no Button1 - it's got one of the
    > converted ASP.Net names with a large prefix.
    >


    for me it works. do you use a master page, or it is an ascx control?
     
    Alexey Smirnov, Aug 31, 2007
    #3
  4. Mufasa

    Mufasa Guest

    Thanks but that doesn't work. When I click on the checkbox, it tells me it
    can't find the object Button1.
    If you look at the source, there is no Button1 - it's got one of the
    converted ASP.Net names with a large prefix.

    J.

    "Alexey Smirnov" <> wrote in message
    news:...
    > On Aug 31, 8:36 pm, "Mufasa" <> wrote:
    >> I have a screen where the user has to agree to stuff. I want them to have
    >> to
    >> click a check box saying they have read it and then have the ok button
    >> become available.
    >>
    >> What's the easiest way to do this?
    >>
    >> TIA - Jeff.

    >
    > <input type="checkbox" name="checkbox" value="I have read the text
    > above"
    > onClick="javascript:document.getElementById('Button1').disabled=!
    > this.checked;" />
    >
    > <asp:Button ID="Button1" runat=server Text="Submit"/>
    >
    > <script language="javascript">
    > document.getElementById('Button1').disabled = true;
    > </script>
    >
     
    Mufasa, Aug 31, 2007
    #4
  5. Re: Required user to read - then click a checkbox and then a butto

    So then change it! If you construct the javascript from the server-side and
    inject it into the page with one of the RegisterClientScriptBlock type
    methods, then you can use the .ClientID property of the button and
    concatenate it into your javascript string.

    -- Peter
    Recursion: see Recursion
    site: http://www.eggheadcafe.com
    unBlog: http://petesbloggerama.blogspot.com
    BlogMetaFinder: http://www.blogmetafinder.com



    "Mufasa" wrote:

    > Thanks but that doesn't work. When I click on the checkbox, it tells me it
    > can't find the object Button1.
    > If you look at the source, there is no Button1 - it's got one of the
    > converted ASP.Net names with a large prefix.
    >
    > J.
    >
    > "Alexey Smirnov" <> wrote in message
    > news:...
    > > On Aug 31, 8:36 pm, "Mufasa" <> wrote:
    > >> I have a screen where the user has to agree to stuff. I want them to have
    > >> to
    > >> click a check box saying they have read it and then have the ok button
    > >> become available.
    > >>
    > >> What's the easiest way to do this?
    > >>
    > >> TIA - Jeff.

    > >
    > > <input type="checkbox" name="checkbox" value="I have read the text
    > > above"
    > > onClick="javascript:document.getElementById('Button1').disabled=!
    > > this.checked;" />
    > >
    > > <asp:Button ID="Button1" runat=server Text="Submit"/>
    > >
    > > <script language="javascript">
    > > document.getElementById('Button1').disabled = true;
    > > </script>
    > >

    >
    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Aug 31, 2007
    #5
  6. Re: Required user to read - then click a checkbox and then a butto

    Howdy,

    Amend it to:

    <input type="checkbox" name="checkbox" value="I have read the text
    above"
    onClick="javascript:document.getElementById('<%=Button1.ClientID
    %').disabled=!this.checked;" />

    <asp:Button ID="Button1" runat=server Text="Submit"/>

    <script language="javascript">
    document.getElementById('<%=Button1.ClientID %>').disabled = true;
    </script>

    HTH
    --
    Milosz


    "Mufasa" wrote:

    > Thanks but that doesn't work. When I click on the checkbox, it tells me it
    > can't find the object Button1.
    > If you look at the source, there is no Button1 - it's got one of the
    > converted ASP.Net names with a large prefix.
    >
    > J.
    >
    > "Alexey Smirnov" <> wrote in message
    > news:...
    > > On Aug 31, 8:36 pm, "Mufasa" <> wrote:
    > >> I have a screen where the user has to agree to stuff. I want them to have
    > >> to
    > >> click a check box saying they have read it and then have the ok button
    > >> become available.
    > >>
    > >> What's the easiest way to do this?
    > >>
    > >> TIA - Jeff.

    > >
    > > <input type="checkbox" name="checkbox" value="I have read the text
    > > above"
    > > onClick="javascript:document.getElementById('Button1').disabled=!
    > > this.checked;" />
    > >
    > > <asp:Button ID="Button1" runat=server Text="Submit"/>
    > >
    > > <script language="javascript">
    > > document.getElementById('Button1').disabled = true;
    > > </script>
    > >

    >
    >
    >
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Aug 31, 2007
    #6
  7. Mufasa

    Mufasa Guest

    I'm using a master page. And that appears to be what is causing the problem.
    I can't get it to even run with the master page. If I make a non-master page
    version, at least then it will run. Although it still doesn't work.

    "Alexey Smirnov" <> wrote in message
    news:...
    > On Aug 31, 9:11 pm, "Mufasa" <> wrote:
    >> Thanks but that doesn't work. When I click on the checkbox, it tells me
    >> it
    >> can't find the object Button1.
    >> If you look at the source, there is no Button1 - it's got one of the
    >> converted ASP.Net names with a large prefix.
    >>

    >
    > for me it works. do you use a master page, or it is an ascx control?
    >
    >
     
    Mufasa, Sep 4, 2007
    #7
  8. On Sep 4, 2:34 pm, "Mufasa" <> wrote:
    > I'm using a master page. And that appears to be what is causing the problem.
    > I can't get it to even run with the master page. If I make a non-master page
    > version, at least then it will run. Although it still doesn't work.
    >


    Peter and Milosz gave you solution for that - a ClientID property

    For example:
    javascript:document.getElementById('<%=Button1.ClientID
    %>').disabled...

    My js-code was for a regular webform.
     
    Alexey Smirnov, Sep 4, 2007
    #8
    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. =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
    Replies:
    2
    Views:
    6,531
    rick74
    May 27, 2008
  2. =?Utf-8?B?Y2FtcHdlcw==?=

    Button in user control becomes disabled

    =?Utf-8?B?Y2FtcHdlcw==?=, Mar 20, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    344
    =?Utf-8?B?Y2FtcHdlcw==?=
    Mar 20, 2006
  3. Amy
    Replies:
    0
    Views:
    1,015
  4. Replies:
    9
    Views:
    1,032
    Juha Nieminen
    Aug 22, 2007
  5. Stef Mientki

    and becomes or and or becomes and

    Stef Mientki, May 22, 2011, in forum: Python
    Replies:
    9
    Views:
    327
    Chris Angelico
    May 28, 2011
Loading...

Share This Page