if the image is an <img> tag, something like this might work:
code:
<input onclick="getimage()">
<script>
function getimage() {
document.getElementById(picture id name).src = 'path to random image generator php file'
}
</script>
If its a css background image, use something like this:
code:
<script>
function getimage() {
document.getElementById(picture id name).className = 'path to random image php file'
}
</script>
<script>
function getimage() {
document.body.style.backgroundImage = 'url(path to random image php file)'
}
</script>