it’s should be something really simple if its possible. anyway of doing so? can’t seem to find it online.
i have a set of checkboxes and textboxes beside it. i only want the textboxes to appear if i check it. my ids are dynamic using php so i cant use javascript out of the loop.
the code below is to test if it works to hide. i am able to hide on click but iam hoping to do the other way round.
while($row = mysql_fetch_array($result)){
echo "<tr>";
echo "<td><input name='CBox $TBCounter' type=\"checkbox\" value=\"{$row['type']}\" onclick=\"document.getElementById('TBox $TBCounter').style.visibility='hidden';\"/></td>";
echo "<td>" . $row['type'] . "</td>
<td><input type=\"text\" name=\"mytext\" id=\"TBox $TBCounter\"></td><br />
</tr>";
$TBCounter++;
}
You can use Javascript’s
window.onloadto make something run every time the page loads.Before your loop…
During your loop, put this
Then make your script (after the loop) look like this