开发者

Update 2 exact same images source using javascript

开发者 https://www.devze.com 2023-03-05 11:24 出处:网络
I using PHP captcha called Cryptographer captchan.fr site I need to use 2 captcha on same page but i have problem they do get generated but when i click refresh only first one refreshes, refresh code

I using PHP captcha called Cryptographer captchan.fr site

I need to use 2 captcha on same page but i have problem they do get generated but when i click refresh only first one refreshes, refresh code looks like this.

document.images.captcha.src='cryptographp.html?cfg=0&&'+Math.round(Math.ran开发者_如何学Cdom(0)*1000)+1;

I tried this code but it only works for first one anyway

document.getElementById('captcha').src='cryptographp.html?cfg=0&&'+Math.round(Math.random(0)*1000)+1;

Now I wanted to do something like this I added name="captcha" to image but this does not work for some reason can someone help me fix it?

document.getElementsByName('captcha').src='cryptographp.html?cfg=0&&+Math.round(Math.random(0)*1000)+1;

I also have jquery attached to page if thats easier.


You can't have more than one element with same ID on page. That may be why it's only hitting the first one. If you add a class to both images called "captcha" you can easily do this with jQuery:

$('.captcha').attr('src', 'cryptographp.html?cfg=0&&'+Math.round(Math.random(0)*1000)+1);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号