Hello,
I have created input bonxes and filled values inside it.
and made it read only
using below code:
<?
foreach($certificated_data as $c)
{
?>
<tr id=<?echo $tr_id; ?> >
<td>
<input type ="textbox" name="certificate[<?=$tr_id?>]['name']" id="name-<?=$tr_id?>" value="<?=$c['Name'] ?>" readonly="readonly" />
</td>
<td>
<input type ="textbox" name="certificate[<?=$tr_id?>]['date']" id="date-<?=$tr_id?>" value="<?=$c['year'] ?>" readonly="readonly"/></td>
<td>
<img width="15" style="background-color:red" height="15" id="edit" alt="Edit certification" onclick="edit_row(this)" src="/employee_skill_set_priti_2/images/update1.jpeg">
</td>
</tr>
<?
$tr_id=$tr_id+1;
}
?>
Now what i want is,
onclick of i.e in edit_row(this) function, make that row editable by removing readonly attribute.
function edit_row(this) is like:
function edit_row(r)
{
var i = r.parentNode.parentNode.rowIndex;
var total_rows=document.getElementById('certificates_table').rows.length;
total_rows=total_rows-1; // we have hardcodly written 1 row
name_id="name-"+ (i-1);
date_id="date-"+ (i-1);
//make all fields disbaled
for(var disable_row=0 ;disable_row<total_rows ;disable_row++)
{
$("#name-"+(disable_row)).attr('readonly', true);
$("#date-"+(disable_row)).attr('readonly', true);
}
// make only this tr editable
$("#name-"+(disable_row)).removeAttr('readonly',false);
$("#name-"+(disable_row)).removeAttr('readonly',false);
}
but it is not working.
what's wrong in this?