Forums

How i can capcha reload

Danilov 24 Jul, 2010
bitte sagen mir, wie kan ich code in form code schreiben.

dafur reload capcha one form reloading.

zum beispiel:
jetzt schreiben:

<div class="form_element cf_captcha">
<input name="chrono_verification" style="vertical-align:top;" type="text" id="chrono_verification" value="" /><img src="http://linguaxtrem.at/components/com_chronocontact/chrono_verification.php?imtype=1" alt="" /></div>


ich moechte:

<img ...bla-bla-bla.... onclick="reloadCaptcha('1')" />

und weiter

function reloadCaptcha(numm)

wie kann ish so machen?

try to translate into English (with google translator on linguaxtrem.at/en/translator.html):

please tell me how I can Write code in form code.. i want reload capcha:
Now write :

<div class="form_element cf_captcha">
<input name="chrono_verification" style="vertical-align:top;" type="text" id="chrono_verification" value="" /><img src="http://linguaxtrem.at/components/com_chronocontact/chrono_verification.php?imtype=1" alt="" /></div>

I want to:

<img ...bla-bla-bla.... onclick="reloadCaptcha('1')" />


and

function reloadCaptcha (number)

how i can make it?
GreyHead 24 Jul, 2010
Hi Danilov,

You can't do this. The ImageVerification is managed server side so you can't refresh it in the browser. Instead you could add an extra submit button that reloaded the page.

Bob
nml375 24 Jul, 2010
Hi Danilov & Bob,
I belive you might achieve this with a little hack..
Changing the URL of the validation image by adding a random field value, should cause the browser to load a new copy from the server, thus updating the key hash in the session storage as well as displaying the new key within the form..

Something like this might do the trick (untested):
Edit chronocontact.html.php around line 177 to add an id to the image:
$imver = '<input name="chrono_verification" style="vertical-align:top;" type="text" id="chrono_verification" value="" />
  <img src="' . $CF_PATH . 'components/com_chronocontact/chrono_verification.php?imtype=' . $MyForm->formparams('imtype') . '" alt="" id="chrono_verification_image"/>';
}

Add this piece of script to your form (requires MooTools):

window.addEvent('domready', function() {
  var verification_base = $('chrono_verification_image').src;
)};

function reloadCaptcha() {
  var image = $('chrono_verification_image');
  image.src = verification_base + '&tmp=' + + Math.floor(Math.random()*11);
}


Add some button, image, or other control that will call the reloadCaptcha() javascript function to get a new captcha.

/Fredrik
GreyHead 26 Jul, 2010
Hi Fredrik,

Yes, that should work . . . I'd forgotten that the session info is updated when the image is generated.

I've tested Fredrik's version and had to make a few small changes. This code is working OK in Joomla 1.5.20 with either version of MooTools. There is no need for the core code hack. In the Form HTML add a button with id='reload'
<div class="form_item">
  <div class="form_element cf_button">
    <input value="Reload Image verfication" name="reload" id="reload" type="button" />
  </div>
  <div class="cfclear"> </div>
</div>
and then add this in the Form JavaScript box
window.addEvent('domready', function() {
  $('reload').addEvent('click', reloadCaptcha);
});

function reloadCaptcha() {
  var img = $$('.cf_captcha img');
  img.setProperty('src', img.getProperty('src') + '&t=1');
};


This does extend the image url a little each time that it is called but that shouldn't be a problem in normal usage.

Bob
Danilov 29 Jul, 2010
Super super super.
Fielen dank.

GreyHead und Fredrik - vielleicht cann diese code in nächster ChronoForm Relise hineingehen

GreyHead and Fredrik - maybe cann enter this code in next Chrono Form Version?
This topic is locked and no more replies can be posted.