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

M

Mufasa

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.
 
G

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.

<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>
 
G

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.

for me it works. do you use a master page, or it is an ascx control?
 
M

Mufasa

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.
 
G

Guest

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
 
M

Mufasa

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.
 
G

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.

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top