Discussion Locked

How to disable checkbox

0 helpful
8 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Using VI6 and SQL7. In the onclick event of the checkbox, how do I disable other checkboxes based on the value of the checkbox? A radio button will not work for this. Code is:

Do until rs1.eof

value=<%=rs1(fieldname)%>

rs1.movenext
loop

Thanks!
Regards, Cora

8 replies

by p7ants

Cora,
Based on what you've provided I can only offer that you evaluate rs1(fieldname) first (possible in a select case construct) then minipulate the checkboxes as needed.

If you can provide more info I could try to offer more help.

Phil

by ladyskydiver

There are 2 columns of checkboxes - each of which are from different recordsets. The first column's recordset contains "ALL," "Item1," "Item 2," etc. The second column's recordset, also, contains "All," "SecondItem1," "SecondItem2," etc. Unfortunately, All needs to be included as well as the ability to select more than one item (hence checkboxes vs. radio buttons). So, the code is:

dim x, y
x=0
DO UNTIL rs1.eof
value=<%=rs1(fieldname)%>>
y =0
DO UNTIL rs2.eof
.<%=y%> value=<%=rs2(fieldname)%>>

y = y + 1
rs2.movenext
LOOP
x = x + 1
rs1.movenext
LOOP

All of rs1 needs to print out as well as rs2. However, once a person clicks on "All" in rs1, then the rest of the items in rs1 need to be either: 1) unchecked or2) hidden and unchecked. The same will be done to rs2.

Does this help or do you need more info? I appreciate your helping me. Thank you!

Regards,
Cora

by aking-robertson

Cora: Are you sure you want to disable all of the other checkboxes? What if the user has made a mistake or has changed his mind and didn't want to click 'All'? Could you not check the value of the checkbox after the page has been submitted to see ifthe user checked the 'All' box and if so, not get the values of any of the other boxes? This would allow you to still obtain the same answer from the form (for both recordsets), but also allow your user to change his/her mind if needed. Also, have you considered using a with mutliple options here instead of checkboxes?

by ladyskydiver

Yes and no. What I want to do is if the user clicks "All" then disable the other checkboxes, but if they click "All" again, re-enable the other checkboxes. The other option is to hide the rest of the page if they select "All" and then show it again if they deselect "All."

Not sure how I would go about doing a select case based on the way the 2 different recordsets are working together.

by aking-robertson

Call a javascript function in the checkbox (ie.ALL) that is run when the clicks the All box. Include the following Javascript function in the header of your page:
Include all the checkboxes to be altered. Hope this helps.

by ladyskydiver

This gives me something to go on. As the checkbox is labeled dynamically (checkbox<%=x%>), it will be a bit different, but I should be able to figure it out from here.

Thank you for your help! It is greatly appreciated.

This discussion is closed to new replies.