请你仔细看看这个来源,因为我提交后没有得到任何结果。 谢谢。
<script type="text/JavaScript">
function reset() {
document.city.citysearch.value = "";
return true;
}
</script>
<form name='city' action='airport.php' method='post'
target='result' onsubmit='return reset()'
>
<input name="citysearch" type="text"
placeholder="Name of the city" size="18">
<input type="hidden" name="submit" value="search">
最佳答案
拥有一个名为“提交”的隐藏字段似乎是非常糟糕的做法。如果您想重置表单字段,请尝试重置按钮( http://www.w3schools.com/tags/att_button_type.asp ),无需 JS:
<form name='city' action='airport.php' method='post' target='result' onsubmit='return reset()'>
<input name="citysearch" type="text" placeholder="Name of the city" size="18">
<input type="hidden" name="search" value="search">
<button type="reset">Reset</button>
<button type="submit">Submit</button>
</form>
更新:听起来您想在提交后重置字段。在服务器端执行此操作。尝试使用属性 value=""返回需要重置的字段。
关于javascript - 提交时清除输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15093190/