2013-10-30 138 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'); 


}