Hi all,
I have an image on a web page (index.php)that I am trying to change when a php script is executed. The part of the php script that calls the function is dependant upon a condition so can't just use the onclick calling condition.
Here is the image
HTML Code:
<img src="../images5/noimage.jpg" id="imgchas" style="float:right" />
here is the part of the php script that calls the javascript function
PHP Code:
//If no errors registred, print the success message
if(isset($_POST['Submit']) && !$errors)
{
echo "<h1>File Uploaded Successfully!</h1>";
//below call javascript to change image
echo '<script type="text/javascript">changge();</script>';
}
?>
and here is the javascript function
HTML Code:
<script type="text/javascript">
function changge()
{
document.getElementById('imgchas').src='uploadedimages/1265720331.jpg';
}
</script>
.
when i run the php script the javascript function is called ok but it fails to find the elementById 'imgchas'. Says imgchas is null.
Any suggestions or comments on this will be greatfully appreciated.
Many Thanks
Adrian