Help. How to implement the button "update image" under the captcha so that a new captcha appears without reloading the page?

In the controller :

$captcha = Captcha::instance('default'); $content = View::factory('index/auth/v_auth_register') ->bind('captcha', $captcha) ->bind('errors', $errors) ->bind('data', $data); 

In the form of :

 <div class="number-box"> <div class="top-box"> <?php echo $captcha; ?> </div> <span class="gray-text"><a href="#">Обновить картинку</a></span> </div> 

    1 answer 1

    Can be done using jQuery. First, add the click processing to the HTML element:

     onclick="reload()" 

    And here is the jQuery function:

     function reload(){ id=Math.floor(Math.random()*1000000); $("img.captcha").attr("src","/captcha/default?id="+id); } 

    You can read more here.

    • Thank! Works! - Demyan112rv