Change img src for captcha

H

Harris Kosmidhs

Hello

I use captcha in an input form for registering. I have the following code:

<p><label><img id="captcha" src="reqcode.php"></label> <input
type="text" name="reqcode">
<br>Press here <a name="cap" href="#cap"
onclick="javascript:changecaptcha('captcha');">if you don't see the
pic.</a>.</p>

reqcode.php produces an image.(http://www.rados.gr/newtest/reqcode.php)

I include a js file in which I have:
function changecaptcha(elem) {
document.getElementById(elem).src =
'http://localhost:81/rados/reqcode.php';
}

If I press to change the image nothing happens. Why? Is it because it
has the same src so it doesn't reload?

thanks
 
H

Harris Kosmidhs

Harris said:
Hello

I use captcha in an input form for registering. I have the following code:

<p><label><img id="captcha" src="reqcode.php"></label> <input
type="text" name="reqcode">
<br>Press here <a name="cap" href="#cap"
onclick="javascript:changecaptcha('captcha');">if you don't see the
pic.</a>.</p>

reqcode.php produces an image.(http://www.rados.gr/newtest/reqcode.php)

I include a js file in which I have:
function changecaptcha(elem) {
document.getElementById(elem).src =
'http://localhost:81/rados/reqcode.php';
}

If I press to change the image nothing happens. Why? Is it because it
has the same src so it doesn't reload?

thanks

Nevermind found it:

function changecaptcha(elem) {
document.getElementById(elem).src = 'reqcode.php?' + (new
Date()).getMilliseconds();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top