PDA

View Full Version : Update the script..



xam
06-27-2006, 03:14 PM
Hello,

I use below code to refresh my image verification codes, when an user click on the refresh button, javascript code will be refresh image code.. but I need to tweak that my code..


<script type="text/javascript">
function reload() {
var now=new Date();
var a=document.getElementById('reload');
a.src='img.php?'+now.getTime();
}
</script>

I want to change below line:
a.src='img.php?'+now.getTime();

with:

img.php?+now.getTime(); + size=6

It means when an user click on the refresh button it should be call img.php?size=6 URL..

Regards.

Twey
06-27-2006, 03:34 PM
function reload() {
document.getElementById('reload').src = "img.php?" + (new Date()).getTime() + "&size=6";
}

xam
06-27-2006, 04:47 PM
function reload() {
document.getElementById('reload').src = "img.php?" + (new Date()).getTime() + "&size=6";
}

First of all thank you very much for your FAST reply :D That's what I need..

By the way, I would like to learn;
a) What means new_date and why we should put this line into script
b) How do I re-update the code again with below feature;
b1) document.getElementById('reload').src = "img.php?" + (new Date()).getTime() + "&size=$MAIN["imageverify"]";

$MAIN["imageverify"] is a php value that I choose from my admin panel.

xam
06-27-2006, 04:52 PM
ok I did it, thanks again


<script type="text/javascript">
function reload() {
document.getElementById('reload').src = "img.php?" + (new Date()).getTime() + "&size=<?=$MAIN[imageverify]?>";
}
</script>

Twey
06-27-2006, 05:04 PM
The new Date() bit is exactly the same as what you did above, but simply avoiding the variables, which aren't necessary since you only use them once.
You missed some quotes out of that code, around imageverify. :)