Check the following code. I hope you are looking for something like this.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<script type="text/javascript">
function init(){
var inputs = document.getElementById('fields').getElementsByTagName('input');
var imgs = document.getElementById('fields').getElementsByTagName('img');
for(var i = 0;i < inputs.length; i++){
var rnd = Math.ceil((Math.random() % 1) * inputs.length);
inputs[i].value = rnd;
imgs[i].src = rnd +".gif";
}
}
window.onload = init;
</script>
</head>
<body>
<div id="maincontent">
<form name="form1">
<div id="fields">
<span><input type="text" name="fld1" id="fld1" value="" /></span><span><img src="" border="0" alt="" /></span>
<span><input type="text" name="fld2" id="fld2" value="" /></span><span><img src="" border="0" alt="" /></span>
<span><input type="text" name="fld3" id="fld3" value="" /></span><span><img src="" border="0" alt="" /></span>
<span><input type="text" name="fld4" id="fld4" value="" /></span><span><img src="" border="0" alt="" /></span>
</div>
</form>
</div>
</body>
</html>
Please find the images used in the above code as the attachment. I hope you'll be able to get how you can change the 'src' attribute of the images using JavaScript from the above mentioned code.
Edit: Place the image files in the same location of the HTML page.
Edit: Please use the [icode][/icode] tags only for short codes.
Bookmarks