0
I’m doubtful for that system in Jquery,
The idea is when to click EDIT on a given line, activate only the inputs
of that particular line of the clicked Edit.
There are also two Editing Privilege, ADM and NORMAL, the NORMAL should only edit the column NAME, the ADM the columns NAME and SALARY; that I got.
var op = "";
var privilegio = "";
function acesso(op){
privilegio = op;
}
function edit(){
if(privilegio == 'adm'){
$(this).parent().next().find('.salario').removeAttr('disabled');
$(this).parent().next().find('.nome').removeAttr('disabled');
}
else{
$('table').find('.nome').removeAttr('disabled');
}
}
<html>
<head>
<title>Desafio</title>
<script src="http://localhost/2015-3/tratamentoevalidacao/jquery-2.2.0.min.js"></script>
<meta charset="UTF-8">
</head>
<body>
<input onclick="acesso('adm')" name="privilegio" type="radio" value="adm">Adm
<input onclick="acesso('normal')" name="privilegio" checked type="radio" value="normal">Normal
<table border="1">
<tr><td>Operações</td><td>Nome</td><td>Salário</td></tr>
<tr>
<td><input class="edit" type="button" onclick="edit('editar')" value="Edit"><input class="excluir" type="button" onclick="excluir()" value="Excluir"></td>
<td><input disabled class="nome" type="text" name="nome"></td><td><input disabled class="salario" type="text" name="salario"></td>
</tr>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
</table>
</body>
</html>