Просто так
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body style="text-align: center; margin: 0px; padding: 0px;">
<img src="http://www.iconarchive.com/icons/archigraphs/oldies/64/Red-Seat-icon.png" onclick = 'this.src == "http://www.iconarchive.com/icons/archigraphs/oldies/64/Red-Seat-icon.png" ? this.src = "http://www.iconarchive.com/icons/archigraphs/oldies/64/Old-Lamp-icon.png" : this.src = "http://www.iconarchive.com/icons/archigraphs/oldies/64/Red-Seat-icon.png"' alt="Кликни на меняяя!" style="cursor: pointer;">
</body>
</html>
Ваш код:
Поменяй на
var test = "/code/captcha.php?" + rndval;