Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2013
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    check box to show text field

    Hi there,
    I tried the solution that i found here on this forum (http://www.developphp.com/forum2011/topic.php?id=5880) (adams one)
    and it works great, except that my checkbox options are put into the form using a recordset and php. When i click a checkbox the hidden field shows next to the top checkbox option, if i choose another checkbox the field disappears.

    I can't make it show a textbox field next to the corresponding checkbox on the page. Below is my code, any help would be much appreciated.

    (my page in development : http://irishdesigngroup.com/adlantic...ddproducts.php)

    Thanks

    Code:
    <head>
    <script type="text/javascript" language="javascript">
    function toggleField(field) {
    	var myTarget = document.getElementById(field);
    	if(myTarget.style.display == 'none'){
    	   myTarget.style.display = 'block';
        } else {
    	   myTarget.style.display = 'none';
    	   myTarget.value = '';
    	}
    }
    </script>
    </head>
    
              <div class="TabbedPanelsContent">Please choose the available colours:<br />
                  <table>
                    <tr>
                      <?php
    $colours_endRow = 0;
    $colours_columns = 2; // number of columns
    $colours_hloopRow1 = 0; // first row flag
    do {
        if($colours_endRow == 0  && $colours_hloopRow1++ != 0) echo "<tr>";
       ?>
                      <td><input type="checkbox" name="colour_option" onclick="javascript:toggleField('myTF');" id="<?php echo $row_colours['colour_name']; ?>" />
                          <?php echo $row_colours['colour_name']; ?></td>
                          <td>- <i><?php echo $row_colours['supplier_code']; ?></i></td>
                          <td id="myrow" style="visibility:hidden"></td>
                      <?php  $colours_endRow++;
    if($colours_endRow >= $colours_columns) {
      ?>
                            <td><input name="myTF" id="myTF" type="text" style="display:none;" /></td>
                          </tr>
                    
                    <?php
     $colours_endRow = 0;
      }
    } while ($row_colours = mysql_fetch_assoc($colours));
    if($colours_endRow != 0) {
    while ($colours_endRow < $colours_columns) {
        echo("<td>&nbsp;</td>");
        $colours_endRow++;
    }
    echo("</tr>");
    }?>
                  </table>
                <br />
              </div>

  • #2
    New Coder
    Join Date
    Apr 2013
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Anyone Please?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •