checkbox in an array

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Jun 2008
Posts: 40
Reputation: enim213 is an unknown quantity at this point 
Solved Threads: 2
enim213 enim213 is offline Offline
Light Poster

checkbox in an array

 
0
  #1
Oct 20th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,076
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is online now Online
Veteran Poster

Re: checkbox in an array

 
0
  #2
Oct 21st, 2008
can you be more clear about it ???????
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 40
Reputation: enim213 is an unknown quantity at this point 
Solved Threads: 2
enim213 enim213 is offline Offline
Light Poster

Re: checkbox in an array

 
0
  #3
Oct 21st, 2008
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.

  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
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 40
Reputation: enim213 is an unknown quantity at this point 
Solved Threads: 2
enim213 enim213 is offline Offline
Light Poster

Re: checkbox in an array

 
0
  #4
Oct 22nd, 2008
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.

  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>
  1. $i++;
  2. }

-enim
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 40
Reputation: enim213 is an unknown quantity at this point 
Solved Threads: 2
enim213 enim213 is offline Offline
Light Poster

Re: checkbox in an array

 
0
  #5
Oct 22nd, 2008
  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. }
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC