如何清除 history.back() 上的文本字段值
How to clear text field value on history.back()
我有这样的 ColdFusion 条件:
<cfif txtTaxFileNo neq "">
<script>
alert("NPWP Already Exist");
history.back();
</script>
<cfabort>
</cfif>
假设 txtTaxFileNo
在上一页中的值为“123”。如何清空 txtTaxFileNo
字段?我已经试过了:
<cfif txtTaxFileNo neq "">
<script>
alert("#JSStringFormat('NPWP Already Exist')#");
history.back();
txtTaxFileNo.value = "";
</script>
<cfabort>
</cfif>
但是,上一页的文本字段不是空的。它的值仍然是“123”。提前致谢。
不要使用history.back()
,因为那样会恢复表单状态。如果要加载新页面,只需加载新页面即可。
<cfif txtTaxFileNo neq "">
<script>
alert("NPWP Already Exist");
window.location = "form URL here";
// or, if the URL is the same
window.location.reload(true);
</script>
<cfabort>
</cfif>
参见 MDN 上的 window.location.reload()
docs。
我有这样的 ColdFusion 条件:
<cfif txtTaxFileNo neq "">
<script>
alert("NPWP Already Exist");
history.back();
</script>
<cfabort>
</cfif>
假设 txtTaxFileNo
在上一页中的值为“123”。如何清空 txtTaxFileNo
字段?我已经试过了:
<cfif txtTaxFileNo neq "">
<script>
alert("#JSStringFormat('NPWP Already Exist')#");
history.back();
txtTaxFileNo.value = "";
</script>
<cfabort>
</cfif>
但是,上一页的文本字段不是空的。它的值仍然是“123”。提前致谢。
不要使用history.back()
,因为那样会恢复表单状态。如果要加载新页面,只需加载新页面即可。
<cfif txtTaxFileNo neq "">
<script>
alert("NPWP Already Exist");
window.location = "form URL here";
// or, if the URL is the same
window.location.reload(true);
</script>
<cfabort>
</cfif>
参见 MDN 上的 window.location.reload()
docs。