2013-07-19 38 views
-1

我很好地提交联系表。一切工作正常,但是当我提交从我想清除所有字段的详细信息。输入不刷新。当我提交联系表格我想从字段中清除?

我的javascript

$(document).ready(function(){ 
    $('#buttonme').click(function(){ 
     $.post("send.php", $("#myform").serialize(), function(response) { 
      $('#contactstatus').html(response); 
       //$('#success').hide('slow'); 
      }); 
     return false; 
    }); 
}); 

我如何可以刷新输入什么,我必须在MyScript可添加

+1

'document.getElementById('myform')。reset();' – adeneo

回答

0

尝试这样的:

$('#myform').each(function(){ 
    this.reset(); 
}); 
0

这应该做的工作:

$('input') 
.val('') 
.removeAttr('checked') 
.removeAttr('selected'); 
0

HTML

<form> 
    <input type="text" /> 
    <input type="reset" id="reset" /> 
    <input type="button" id="buttonme" value="Submit"/> 
</form> 

JS

$(document).ready(function() { 
    $("input:reset").hide(); 
    $('#buttonme').click(function() { 
     $("input:reset").click(); 
    }); 
}); 

工作演示http://jsfiddle.net/cse_tushar/8URw4/

在你的情况 在福尔添加HTML

<input type="reset" id="reset" /> 

JS

$(document).ready(function(){ 
    $('#buttonme').click(function(){ 
     $.post("send.php", $("#myform").serialize(), function(response) { 
      $('#contactstatus').html(response); 
       //$('#success').hide('slow'); 
      $("input:reset").click();//add this to your code 
      }); 
     return false; 
    }); 
}); 

,或者你可以简单地使用

JS

$('form').trigger('reset'); 
+0

感谢brooo。甚至为什么会投下我的票。我不知道。但我得到了解决方案。所有 – marvan

+0

不知道为什么他们投票给你:/如果你已经把解决方案作为答案,以便其他有相同问题的人可以找到解决方案。 –