943,518 Members | Top Members by Rank

Ad:
Dec 6th, 2008
0

Help me ->very son->CheckBox

Expand Post »
Hello people
i created this code:
<script langauge=javascript>
function baby(a,b)
{
document.p.text=a;
document.p.cat[b].checked=true;
}
</script>

<form name="p" >
<input type="checkbox" name="cat[10]">
<input type="checkbox" name="cat[11]">
<input type="text" name="text">
</form>

<a href="javascript:baby('Hello',10);">Click Here</a>


when i click on The "Click Here" the textbox show me Hello but the checkbox doesn't work and dosen't get check.

Now How can i do? how can i check of the checkboxes?


Another question:
you assume that i have some checkboxes with the diffrent name such as
<input type="checkbox" name="cat[110]">
<input type="checkbox" name="cat[101]">
<input type="checkbox" name="cat[011]">
.
.
.

now how can i uncheck them at a moment?
Last edited by baby_1; Dec 6th, 2008 at 2:38 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
baby_1 is offline Offline
13 posts
since Nov 2008
Dec 6th, 2008
0

Re: Help me ->very son->CheckBox

Hi,

try this
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script langauge=javascript>
  4. function baby(a,b)
  5. {
  6.  
  7. document.p.text.value=a;
  8. document.getElementById(b).checked=1;
  9. }
  10. </script>
  11. </head>
  12. <body>
  13.  
  14. <form name="p" >
  15. <input type="checkbox" name="cat(10)" id=10 >
  16. <input type="checkbox" name="cat(11)" id=11 >
  17. <input type="text" name="text">
  18. </form>
  19.  
  20. <a href="javascript:baby('Hello',11);">Click Here</a>
  21. </body>
  22. </html>
Reputation Points: 13
Solved Threads: 29
Junior Poster
kb.net is offline Offline
169 posts
since Aug 2007
Dec 7th, 2008
0

Re: Help me ->very son->CheckBox

Thanks a lot kb.net , Thank you very much ,
dear now how can i unchecked al of them with diffrent id or name at a moment? for example:

<input type="checkbox" name="cat(5)" id=5>
<input type="checkbox" name="cat(9)" id=9>
<input type="checkbox" name="cat(20)" id=20 >
<input type="checkbox" name="cat(11)" id=11 >

and how can i hide them?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
baby_1 is offline Offline
13 posts
since Nov 2008
Dec 7th, 2008
0

Re: Help me ->very son->CheckBox

no one can help me? i want to do this

how can i unchecked al of them with diffrent id or name at a moment? for example:
<input type="checkbox" name="cat(5)" id=5>
<input type="checkbox" name="cat(9)" id=9>
<input type="checkbox" name="cat(20)" id=20 >
<input type="checkbox" name="cat(11)" id=11 >
Reputation Points: 10
Solved Threads: 0
Newbie Poster
baby_1 is offline Offline
13 posts
since Nov 2008
Dec 7th, 2008
0

Re: Help me ->very son->CheckBox

Please help me
Reputation Points: 10
Solved Threads: 0
Newbie Poster
baby_1 is offline Offline
13 posts
since Nov 2008
Dec 8th, 2008
0

Re: Help me ->very son->CheckBox

Hi,

Amend your code to look something like this

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script langauge=javascript>
  4. function baby()
  5. {
  6. for (var x= 1; x<=4 ;x++)
  7. document.getElementById(x).checked=0;
  8. }
  9. </script>
  10. </head>
  11. <body>
  12.  
  13. <form name="p" >
  14. <input type="checkbox" name="cat(5)" id=1 >
  15. <input type="checkbox" name="cat(9)" id=2 >
  16. <input type="checkbox" name="cat(10)" id=3 >
  17. <input type="checkbox" name="cat(12)" id=4 >
  18. </form>
  19.  
  20. <a href="javascript:baby();">Click Here</a>
  21. </body>
  22. </html>
Reputation Points: 13
Solved Threads: 29
Junior Poster
kb.net is offline Offline
169 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: get image size and how to make changes
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Binary to decimal using bitwise operators





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC