2013-10-30 44 views
0

我想提交后清除文本字段。请帮我:(提交后清除表格

<form name ="client" id="client" method="POST" action="index.php" > 
    <input type="hidden" name="id" id="id" > 

     <label>name</label> 
     <input type="text" name="nombre" id="nombre" value=""> <br /> 

     <label>surname</label> 
     <input type="text" name="apellido" id="apellido"> <br /> 

     <label>age</label> 
     <input type="text" name="fecha" id="fecha" > <br /> 

     <label>sex</label> 
     <select name="peso" id="peso" > <br /> 
     <option>male</option> 
     <option>female</option> 
     </select> <br /> 


     <input id="submit" type="submit" name="submit" value ="submit"/> 

</form> 
+1

它看起来像你的文章大多是代码;请添加更多的细节。 –

+0

Firefox刷新页面后会记住表单内容。你可以使用javascript手动设置每个输入的值为空字符串。 – Plato

回答

0

好,如果你的页面是刷新,字段应该被清洗自理,如果页面不刷新,您可以使用JavaScript document.getElementById('nombre').value = "";例如

0

不知道如何”重新处理表单提交,但目前还不清楚您需要的解决方案。但是,这里的东西,你可以实现使用jQuery您所需要的。

$("form").submit(function(){ 
    $(this).find("input[type=text], select").val(""); 
}); 
+0

它在表格上添加cleard字段。行动后我想清除。 – user2938787

0

这将重置您的形式(或其他)后提交,也包括其他类型的html输入。

希望这会有所帮助。

//使用

ResetFormControlValues('your form id') 


function ResetFormControlValues(parent) { 

    $(':input', '#' + parent) 
    .val('') 
    .removeAttr('checked') 
    .removeAttr('selected'); 
    $('input:radio', '#' + parent).removeAttr('checked'); 


}