Hi,
I would like to display my database data in text fields form.
I would like to have all the text fields to be locked (read only), so I added readonly attribute into the text fields. Moreover, I would like to add a button "EDIT" at each row, so that the specific row become unlock/editable.
The problem now is that my code is not working! Anyone can help?
I had created a EDIT! button to trigger the function.
The following is the code to display all the data in text fields form:
<?php
$i = 0;
while ($row=mysql_fetch_array($result)){
?>
<tr>
<form name="form1" action="submitAction.php" method="post">
<td width="72" ><input type="text" autocomplete=off readonly=true name="ProjectName<?php echo $row['No'];?>" value="<?php echo $row['ProjectName'];?>" size="20" style="font-size: 9"></font></td>
<td width="72" ><input type="text" autocomplete=off readonly=true name="DeviceType<?php echo $row['No'];?>" value="<?php echo $row['DeviceType'];?>" size="15" style="font-size: 9"></font></td>
<td width="64" ><input type="button" value="EDIT!" onclick="removeAlignment(<?php echo $i; ?>);"></font></td>
<td width="67" style="font-size: 12">
<select name="action" onchange="submitRequest(<?php echo $i; ?>);">
<option value=>Ongoing </option>
<option value="<?php echo $row['ProjectName'];?>">Complete</option>
<option value="<?php echo $row['No'];?>">Update</option>
</select>
</form>
</td>
</tr>
<?php
$i++;
}
?>
And the following is the javascript code:
<script language="JavaScript">
function removeAlignment(id){
var read=document.getElementById("txt")
.removeAttribute("readonly",0);
}
</script>
Thanks!