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).
|
|
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 )
<html> <head> <script type="text/javascript"> function check() { var check1 = document.TestForm.Check1 if (check1.checked = true) { document.TestForm.Check2.checked = false; document.TestForm.Check3.checked = false; } } </script> </head> <body> <form method="post" name="TestForm"> <input type="checkbox" value="1" name="Check1" onchange="check();">If I check this checkbox...</input> <br /><br /> <input type="checkbox" value="2" name="Check2" checked="checked">This one and...</input> <input type="checkbox" value="3" name="Check3" checked="checked">this one should uncheck!</input> </form> </body> </html>
If you have any problems then please let me know.
Hope this helps,
Dr B
|
|
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.
|
|
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....................
|
|
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
|
|
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.
|
|
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?
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
|