passing javascript actions within php while loop
<p>I need the following functionality :</p>

<p>"When a checkbox is checked, the corresponding textbox must be highlighted and user could be able to enter some text into that.."</p>

<p>Checkboxes are working, but when a checkbox is checked, the corresponding textbox is not activating, how to solve this?</p>

<p>Here is my php code :</p>

<pre><code>&lt;?php
if ($handle = opendir('/year_no/albums')) {
    $blacklist = array('.', '..');
    while (false !== ($file = readdir($handle))) {
        if (!in_array($file, $blacklist)) {
            echo "&lt;form name='form1'&gt;
            &lt;div class='controlset-pad'&gt;
            &lt;font color='black'&gt;&lt;label&gt;&lt;input type='checkbox' name='album[]' value='$album' onclick='enable_text(this.checked)' class='medium'/&gt;&lt;span&gt;$album&lt;/span&gt;&lt;/label&gt;&lt;br/&gt;&lt;/div&gt;​";
            echo"&lt;script&gt; 
            function enable_text(status)
            {
                status=!status;
                document.form1.other_name.disabled = status;
            }
            &lt;/script&gt;";
            echo "&lt;div class='field4'&gt;&lt;label&gt;Add your comment here&lt;/label&gt;&lt;input type='text' name='other_name' class='medium' disabled='disabled'/&gt;&lt;/div&gt;&lt;/form&gt;";
        }
    }
    closedir($handle);
}
?&gt;
</code></pre>

<p>MODIFIED CODE:</p>

<pre><code>&lt;script&gt; 
function enable_text(status, sub)
{
status=!status;
document.getElementById(sub).disabled = status;
}
&lt;/script&gt;
&lt;form name='form1'&gt;
&lt;?php
if ($handle = opendir('/year_no/albums')) {
    $blacklist = array('.', '..');
    while (false !== ($file = readdir($handle))) {
        if (!in_array($file, $blacklist)) {
echo "&lt;div class='controlset-pad'&gt;
&lt;font color='black'&gt;&lt;label&gt;&lt;input type='checkbox' name='file[]' value='$file' onclick='enable_text(this.checked, $file)' class='medium'/&gt;&lt;span&gt;$file&lt;/span&gt;&lt;/label&gt;
&lt;/div&gt;";
echo "&lt;div class='field4'&gt;&lt;label&gt;Add your comment here&lt;/label&gt;&lt;input type='text' name='sub' id='$file' class='medium' disabled='disabled'/&gt;&lt;/div&gt;";
        }
    }
    closedir($handle);
}
?&gt;
&lt;/form&gt;
</code></pre>
