This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to refresh captcha text with JS or render?

 
Kashif Ayyaz
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using simpleCaptcha library to display captcha using servlet. requirement is to refresh the captcha if refresh button is pressed.

I have tried with render facility as well as using javascript but nothing is working on my end. following is my code for refresh button, captcha display and javascript function.

<h:graphicImage value="/img/refresh-s.png" onclick="changeCaptcha()" />

<f:verbatim>
<img id="myCaptcha" src="/RoyalCourtPortal-portlet/simpleImg" width="120" height="30" />
</f:verbatim>


function changeCaptcha(){
$('myCaptcha').attr('src', '/RoyalCourtPortal-portlet/simpleImg' );
}

/////////////////////////////////////////////////////////////////////////////////////////
Please while answering provide code example as I am very new with javascirpt.


Thanks in advance

regards

 
Tim Holloway
Saloon Keeper
Pie
Posts: 17639
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://myfaces.apache.org/tomahawk-project/tomahawk20/tagdoc/t_captcha.html
 
Kashif Ayyaz
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
got the solution


it was like

$("#myCaptcha").attr("src", "/RoyalCourtPortal-portlet/simpleImg?"+new Date().getTime());

instead of

$('myCaptcha').attr('src', '/RoyalCourtPortal-portlet/simpleImg?'+new Date().getTime());
or

$('myCaptcha').attr('src', '/RoyalCourtPortal-portlet/simpleImg'); as they are asp syntax styles according to my knowledge.

 
Tim Holloway
Saloon Keeper
Pie
Posts: 17639
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hint: use the Code button in the message editor to wrap special tags around code or XML so that they will format in a more readable way.

Also, be very careful about coding "$" jQuery clauses on a JSF View Definition. The "$" may be intercepted and mis-interpreted by the EL processor, which assigns a different meaning. It's safer to use the alternate "jQuery()" syntax.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic