www.webdeveloper.com
Results 1 to 2 of 2

Thread: PHP-JAVASCRIPT multiple checkbox disabling textbox

  1. #1
    Join Date
    Apr 2011
    Posts
    67

    Wink PHP-JAVASCRIPT multiple checkbox disabling textbox

    hello!

    can you please help me to achieve this?

    i have a multiple checkbox and multiple textbox.. and it is inside by mysql_fetch_array what i want to do is,, once i checked the checkbox it enable a textbox that i only want.

    PHP Code:
    <script language="javascript">
       

     
       function enableDisable()
        {
    var checkBoxes = document.getElementsByName('MyCheckBox');
           // alert(checkBoxes.length);
                   var param = "";
                    for (var counter=0; counter < checkBoxes.length; counter++) {
                                    if (checkBoxes[counter].checked == true) {
                                                  param += checkBoxes[counter].value;
                                                //document.MyForm.time_bound[counter].disabled==false;
                                                //param +=document.MyForm.MyCheckBox[counter].value;
                                    
                                    }
                                    
                    }
                    
    alert(param);


        
      }
        
    </script>

    <?php $ctr=0;
    while(
    $row=mysql_fetch_array($sql2)){  ?>
    <tr>
    <td><input type="checkbox" name="MyCheckBox" onclick="enableDisable();" value="<?php echo $ctr+=1?>">
    <input type="text" id="time_bound" name="time_bound[]" value="<?php echo $row['time_bound']; ?>" disabled="true">
    </td>
    </tr>

    <?php }?>
    i did not actually add the other codes because its not that important i think
    Last edited by ballball; 03-27-2013 at 08:27 PM.

  2. #2
    Join Date
    Apr 2011
    Posts
    67
    okay

    i have this
    <script>
    function enabledisable(){
    textbox=document.getElementsByName("mytextbox[]");
    checkbox=document.getElementsByName("mycheckbox[]");
    }

    </script>

    while(){
    <input type="checkbox" name="mycheckbox[]" onchange="enabledisable()" value="">
    <input type="text" name="text" name="mytextbox[]" value="" disabled="true">
    }
    it will display many copies because of the record from database what i need to to is when i checked a particular checkbox it will enable my desired textbox, its easy to it if its static but i dont know what approach will i do if its dynamic

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles