Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

regarding checkbox

Question posted by: yash777 (Newbie) on March 28th, 2008 10:31 AM
hello all,

this is my first post on the site.

I just want to Know the javascript which is used to disable the checkboxes on click of another checkbox?

means if we click on checkbox, the other 2, 3 checkboxes should be disabled.

Actually, i am retriving Questions and their answers from SQL Server using ASP. And the ID's of these Questions and answers are set as value to the respective checkboxes.

If, I clicked on the question checkbox then the answers checkboxes should be disabled.

pl help me
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
DrBunchman's Avatar
DrBunchman
Moderator
756 Posts
March 28th, 2008
12:29 PM
#2

Re: regarding checkbox
Hi yash777,

Welcome to The Scripts!

Give this script a try. It's pretty simple and you should be able to adapt it for your own uses.
Code: ( text )
  1. <html>
  2. <head>
  3.  <script type="text/javascript">
  4.  function check()
  5.  {
  6.  var check1 = document.TestForm.Check1
  7.  
  8.  if (check1.checked = true)
  9.   {
  10.   document.TestForm.Check2.checked = false;
  11.   document.TestForm.Check3.checked = false;
  12.   }
  13.  }
  14.  </script>
  15. </head>
  16. <body>
  17.  <form method="post" name="TestForm">
  18.   <input type="checkbox" value="1" name="Check1" onchange="check();">If I check this checkbox...</input>
  19.   <br /><br />
  20.   <input type="checkbox" value="2" name="Check2" checked="checked">This one and...</input>
  21.   <input type="checkbox" value="3" name="Check3" checked="checked">this one should uncheck!</input>
  22.  </form>
  23. </body>
  24. </html>


If you have any problems then please let me know.

Hope this helps,

Dr B

Reply
yash777's Avatar
yash777
Newbie
20 Posts
March 28th, 2008
01:54 PM
#3

Re: regarding checkbox
thanks for ur reply ,

but Actually i am assigning an ASP value to the checkbox and i want to "disable" the answer checkboxes if a question checkbox is checked.

As it is coming from database i am not sure of no.of Question and Answer checkboxes.

Reply
yash777's Avatar
yash777
Newbie
20 Posts
March 28th, 2008
02:02 PM
#4

Re: regarding checkbox
please reply,

i am not able to reply u again as my office timing is over.

but pl post ur answer.

i will check it tomorrow at 10 am.(pl stay connected)

waiting for ur reply....................

Reply
DrBunchman's Avatar
DrBunchman
Moderator
756 Posts
March 28th, 2008
02:57 PM
#5

Re: regarding checkbox
Quote:
Originally Posted by yash777
thanks for ur reply ,

but Actually i am assigning an ASP value to the checkbox and i want to "disable" the answer checkboxes if a question checkbox is checked.

As it is coming from database i am not sure of no.of Question and Answer checkboxes.


I'm afraid I don't understand what it is you're trying to do.

Can you try to explain it a little more clearly with an example and some code if possible? The clearer the question is the more chance we have of quickly helping you out.

Dr B

Reply
yash777's Avatar
yash777
Newbie
20 Posts
March 29th, 2008
05:00 AM
#6

Re: regarding checkbox
thanks for ur reply Dr.B,

this is my code:

<%while not rs.eof%>//////first recordset of Questions
<tr>
<td height="18" align="center"><input type="checkbox" name="chkquestion" value="<%=ID%>"></td>
</tr>

<% while not rsd.eof%>//////second recordset of Answers
<tr>
<td height="18" align="center"><input type="checkbox" name="chksolution" value="<%=rsd("S_id")%>"></td>
</tr>

<%wend
rsd.movenext()

wend

rs.movenext()
%>


So, i want to disable the answer checkbox if the question checkbox is checked.

Reply
DrBunchman's Avatar
DrBunchman
Moderator
756 Posts
April 3rd, 2008
08:01 AM
#7

Re: regarding checkbox
Are the questions and answers coming as pairs? So if I check Question 1(Q1) then Answer 1 (A1) is disabled and if I check Q2 then A2 is disabled and so on?

Reply
Reply
Not the answer you were looking for? Post your question . . .
180,431 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top ASP Forum Contributors