943,753 Members | Top Members by Rank

Ad:
Oct 20th, 2008
0

checkbox in an array

Expand Post »
hi, im enim and its my first time to post here in javascript because im into php.

my question is:

1.) Is it possible to have two checkbox in a row (with different value), the one is hidden and if i check the the visible checkbox, the other one will be checked too..


2.) and the scenario above will be in an array like when i have 10 rows..

pls. anyone really need your help thanks
Similar Threads
Reputation Points: 11
Solved Threads: 2
Light Poster
enim213 is offline Offline
40 posts
since Jun 2008
Oct 21st, 2008
0

Re: checkbox in an array

can you be more clear about it ???????
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Oct 21st, 2008
0

Re: checkbox in an array

this is what im talking about.. its just a single row.. i need to use it in array (for example 10 rows) but it doesn't work. i know i need some javascript add'l code but i don't know how to continue.

the controller will be the visible..the other two checkbox will be hidden.

php Syntax (Toggle Plain Text)
  1. <?php include "dbconn.php";?>
  2. <html>
  3. <head>
  4. <SCRIPT LANGUAGE="JavaScript">
  5. <!--
  6.  
  7. <!-- Begin
  8. function Check(chk)
  9. {
  10. if(document.myform.Check_ctr.checked==true)
  11. {
  12. for (i = 0; i < chk.length; i++)
  13. chk[i].checked = true ;
  14. }
  15. else
  16. {
  17. for (i = 0; i < chk.length; i++)
  18. chk[i].checked = false ;
  19. }
  20.  
  21. }
  22.  
  23. // End -->
  24. </script>
  25. </head>
  26. <body>
  27. <form name="myform" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  28. <div>
  29. <div style="width: 200px; height: 30px"><input type="checkbox" name="Check_ctr" value="yes" onClick="Check(document.myform)"/>controller</div>
  30. <div style="width: 200px; height: 30px">
  31. <div style="float: left"><input type="checkbox" name="providername" value="premium"/></div>
  32. <div style="float: left"><input type="checkbox" name="id" value="2"/></div>
  33. </div>
  34. <div style="width: 200px; height: 30px">
  35. <div><input type="submit" name="submit" value="Submit"/></div>
  36. </div>
  37. </div>
  38. </form>
  39. </body>
  40. </html>

thanks in advance.
-enim
Reputation Points: 11
Solved Threads: 2
Light Poster
enim213 is offline Offline
40 posts
since Jun 2008
Oct 22nd, 2008
0

Re: checkbox in an array

hey guys, i think i just dont know how to expalin my problem.. but its ok now. i have it solved myself. i will post the code just in case someboby need it.

php Syntax (Toggle Plain Text)
  1. //records from database
  2. $i = 0;
  3. while($row = mysql_fetch_array($result))
  4. {
<div class="cellContainer" style="background-color: <?php echo $color;?>">
<div class="button1"><input type="checkbox" id="fld1[<?php echo $i;?>]" name="checkbox[]" value="<?php echo $row['destination']; ?>" onClick="document.getElementById('fld2[<?php echo $i;?>]').checked = document.getElementById('fld1[<?php echo $i;?>]').checked"/></div>
<div class="button1" style="visibility: hidden"><input type="checkbox" id="fld2[<?php echo $i;?>]" name="idprovider[]" value="<?php echo $row['id_provider'];?>"/></div>
php Syntax (Toggle Plain Text)
  1. $i++;
  2. }

-enim
Reputation Points: 11
Solved Threads: 2
Light Poster
enim213 is offline Offline
40 posts
since Jun 2008
Oct 22nd, 2008
0

Re: checkbox in an array

php Syntax (Toggle Plain Text)
  1. $i = 0;while($row = mysql_fetch_array($result)){
  2.  
  3. <div class="cellContainer" style="background-color: <?php echo $color;?>">
  4. <div class="button1"><input type="checkbox" id="fld1[<?php echo $i;?>]" name="checkbox[]" value="<?php echo $row['destination']; ?>" onClick="document.getElementById('fld2[<?php echo $i;?>]').checked = document.getElementById('fld1[<?php echo $i;?>]').checked"/></div>
  5. <div class="button1" style="visibility: hidden"><input type="checkbox" id="fld2[<?php echo $i;?>]" name="idprovider[]" value="<?php echo $row['id_provider'];?>"/></div>
  6.  
  7. $i++;
  8. }
Reputation Points: 11
Solved Threads: 2
Light Poster
enim213 is offline Offline
40 posts
since Jun 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: Ajax for XML editing?
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: <select onChange=""> problem





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


Follow us on Twitter


© 2011 DaniWeb® LLC