Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

Array in Checkboxes

Javascript coding ..

Moderators: macek, egami, gesf

Array in Checkboxes

Postby whitemoss » Sun Feb 11, 2007 10:52 pm

Hi All,

I need to write a javascript code where when user clicked the checkbox, then the textboxes beside it appears. I already write that code but unfortunately, it didn't work as expected. the textboxes didnt appear even though the checkbox has been checked. Below are the code:

Code: Select all
<script language="javascript">

function show(chkbox,txt1,txt2)
{   
   if (chkbox.checked == true)
   {
      document.getElementById(txt1).style.visibility = "visible";
      document.getElementById(txt2).style.visibility = "visible";
   }
   else
   {
      document.getElementById(txt1).style.visibility = "hidden";
      document.getElementById(txt2).style.visibility = "hidden";
   }
}

</script>


Code: Select all
<form name="form" method="post" action="bcastTime.php">
     <table width="335"  border="0" align="center" bgcolor="#CCCCCC" id="myTable[]">
   
        <?    
         $query = "Select * from BcastTime";
         $result= mysql_query($query) or die ("Query Failed!");
         $i = 0;
      ?>
         
              
      <?
         while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
         {
            $StartTime = $row["StartTime"];
            $EndTime= $row["EndTime"];
            $Day   = $row["Day"];
      ?> <tr>
            <td>
            <?
               echo "<input id='chkbox[$i]' type='checkbox' value=$Day onclick='show(this,'txt1[$i]','txt2[$i]');'>";
               echo $Day;
            ?>
            </td>
            <td>
            <?
               echo "<div align='center'>";
               echo "<input name='StartBcast' type='text' id='txt1[$i]' value=$StartTime size='10' style='visibility:hidden;'>";
                  echo "</div>";
            ?>
            </td>
            <td>
            <?
               echo "<div align='center'>";
               echo "<input name='EndBcast' type='text' id='txt2[$i]' value=$EndTime size='10' style='visibility:hidden;'>";
               echo "</div>";
            ?>
            </td>
           </tr>   
         <? $i++; }  ?>   
      </table>
      <table border="0" p align="center" width="340">
         <tr>
                <td colspan="6"><div align="left"><span class="style11">* Use 24 hour format only </span></div></td>
           </tr>
         <tr><td>&nbsp;</td></tr>
         <tr>
                <td colspan="6"><div align="center">
               <input type="submit" name="Submit" value="Submit">
                     <input type="reset" name="Submit2" value="Reset"></div></td>
           </tr>
      </table>
      </form>


Any help is much appreciated..Thanks a lot
whitemoss
New php-forum User
New php-forum User
 
Posts: 55
Joined: Thu Apr 14, 2005 1:28 am
Location: Malaysia

Postby sanketce » Tue Feb 13, 2007 5:44 am

try below code necessary modification in your code

Code: Select all
document.getElementById("yourid").style.display="block";
document.getElementById("yourid").style.display="none";
sanketce
New php-forum User
New php-forum User
 
Posts: 90
Joined: Fri Dec 02, 2005 3:23 am


Return to JavaScript

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.