I've got the following table which is build for every guest entry in a MySQL table.
echo '<tr>
<td>'.$gastId[$i]." ".$voornaam[$i].'</td>
<td><input type="radio" name=present'.$gastId[$i].'[] value=1 onclick="setReadOnly(this)" checked></td>
<td><input type="radio" name=present'.$gastId[$i].'[] value=2 onclick="setReadOnly(this)"></td>
<td><input type="text" name="artiest[]" value="'.$artiest[$i].'"></td>
<td><input type="text" name="titel[]" value="'.$titel[$i].'"></td>
</tr>';
I would like to disable the two fields artiest
(artist) and titel
(title) base on the radio button present'.$gastId[$i].
I was trying to solve it with javascript, but I have little experience with javascript. Is there a way link the radio buttons and text field per row by ID or something?
<script language='javascript'>
<!-- //
function setReadOnly(obj)
{
if(obj.value == 1)
{
document.forms[0].artiest.readOnly = 0;
} else {
document.forms[0].artiest.readOnly = 1;
}
}
// -->
</script>
Thank you very much for your help!
EDIT 21-10-2012
Sorry I've should have been more clear.
If the table looks like this:
------------------------------------------------
| P | NP | Artist | Title |
------------------------------------------------
| X | | Enabled | Enabled |
------------------------------------------------
| | X | Disabled | Disabled |
------------------------------------------------
etc
So the radio button of that row controls if the fields in that same row are enabled or disabled.