clear inputbox onclick image

Go To StackoverFlow.com

0

this line renews the captcha image, it should clear the inputbox 'captcha' aswell.

    <div id="refresh_button"><a href="#" onclick="refreshimg();return false;"><img src="refresh.gif"/></a></div>

    <input type="text" maxlength="6" name="captcha" id="captcha" class="captcha_inputbox" />

So I have to modify the onClick, but I can't find this, not even with google.

Your help is much appreciated

2012-04-03 21:52
by Maarten Hartman


2

You can clear out the textbox's value by using:

document.getElementById('captcha').value = '';

Alternatively, if you're using jQuery:

$('#captcha').val('');
2012-04-03 21:58
by Scott Hamper
thanks, you've shown me the right path, fixed it: - Maarten Hartman 2012-04-03 22:04


1

it would be better to do this in script tags instead. For instance you can do something like this:

<script type='text/javascript'>
   function refreshimg() {
      // do the refreshing here

      // since your input text has an id of 'captcha'
      document.getElementById("captcha").value = "";

      return false;
   }
</script>

then in your HTML, you would do

<div id="refresh_button"><a href="#" onclick="return refreshimg();"><img src="refresh.gif"/></a></div>
<input type="text" maxlength="6" name="captcha" id="captcha" class="captcha_inputbox" />
2012-04-03 22:00
by Rorchackh
thanks for your input mate, fixed it : - Maarten Hartman 2012-04-03 22:05