When the option rond is selected in the select-list edit_type below I need input-field edit_maat_2 to be changed to readonly but nothing is happening.
This is my code:
<select class="form-control" id="edit_type['.$i.']" name="edit_type" onclick="show_dim(this, '.$i.')">
<option ';if($row_table_1['type'] == 'rond') { echo 'selected="selected"';} echo 'value="as">Staf rond</option>
<option ';if($row_table_1['type'] == 'buis') { echo 'selected="selected"';} echo 'value="buis">Buis</option>
</select>
<input type="number" class="form-control" id="edit_maat_2['.$i.']" name="edit_maat_2" value="'.$row_table_1['maat_2'].'">
<script type="text/javascript">
function show_dim(selectVeld, nr)
{
if(document.getElementById('edit_type['+nr+']').value == 'rond') {
document.getElementById('edit_maat_2['+nr+']').attr('readonly','readonly'); }
}
</script>
$i is generated and is function ok.
When I check this is console mode I see this error: Uncaught ReferenceError: e is not defined I am not using the variable e any wehere(?)
Any suggestions?
$i? Is the HTML generated withphp?$iis generated and is function ok.<>and create a minimal reproducible example with PURE HTML and JS only. No need for PHP