2012-04-03 63 views
0

此行更新驗證碼圖像,它應該清除輸入框'captcha'以及。清除輸入框onclick圖像

<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" /> 

所以我必須修改onClick,但我找不到這個,甚至沒有與谷歌。另外

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

,如果你使用jQuery:

你的幫助是非常讚賞

回答

2

您可以通過使用清除文本框的值

$('#captcha').val(''); 
+0

謝謝,你已經證明了我在正確的道路上,把它:) – 2012-04-03 22:04:51

1

它會更好而是在腳本標記中執行此操作。舉例來說,你可以做這樣的事情:

<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> 

然後在你的HTML,你會做

<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" /> 
+0

感謝您的輸入隊友,修好了:) – 2012-04-03 22:05:27