Thank you so much for your link. But let me ask another question.
echo '
<SCRIPT TYPE="JavaScript">
var r = new resetimage($src);
ri.write();
</SCRIPT> ';
$src is php variable. How can I pass this $src to javascript fun. I have already tried the following style. But it also doesnt work.
echo "var r = new resetimage($src);" ;
echo "ri.write();" ;