2
I have a little problem in Javasscript. I have a table with several lines, in each row has data and a check at the end of the line that, when clicked, changes the image. Very similar to the Joomla listing, who knows, will understand.
I even managed, right here the script that changes the image, but, changes in one line. How to make the event happen on all lines?
Follows the code:
function test() {
if (document.pic1.src == 'https://cdn3.iconfinder.com/data/icons/flat-actions-icons-9/792/Tick_Mark_Dark-32.png') {
document.pic1.src = 'https://cdn3.iconfinder.com/data/icons/flat-actions-icons-9/792/Close_Icon_Dark-32.png';
} else if (document.pic1.src == 'https://cdn3.iconfinder.com/data/icons/flat-actions-icons-9/792/Close_Icon_Dark-32.png') {
document.pic1.src = 'https://cdn3.iconfinder.com/data/icons/flat-actions-icons-9/792/Tick_Mark_Dark-32.png';
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="#">
<table>
<tr>
<td>Zé Mané</td>
<td>
<img name="pic1" src="https://cdn3.iconfinder.com/data/icons/flat-actions-icons-9/792/Tick_Mark_Dark-32.png" onclick="test()" />
</td>
</tr>
<tr>
<td>João das Paçocas</td>
<td>
<img name="pic2" src="https://cdn3.iconfinder.com/data/icons/flat-actions-icons-9/792/Tick_Mark_Dark-32.png" onclick="test()" />
</td>
</tr>
<tr>
<td>Carlão Pé de Burro</td>
<td>
<img name="pic3" src="https://cdn3.iconfinder.com/data/icons/flat-actions-icons-9/792/Tick_Mark_Dark-32.png" onclick="test()" />
</td>
</tr>
<tr>
<td>Zezão Mão de Entortar Cano</td>
<td>
<img name="pic4" src="https://cdn3.iconfinder.com/data/icons/flat-actions-icons-9/792/Tick_Mark_Dark-32.png" onclick="test()" />
</td>
</tr>
</table>
</form>
</body>
</html>
Who can tell me how I do, I thank you in advance.
Hello Sam!!! Thanks for the reply. I’m sorry, but I didn’t see that you had posted.
– Décio Rocha
Could you tell me how I do the "Accept" of Mauro’s answer???
– Décio Rocha