本文介绍了如何清除history.back()上的文本字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的ColdFusion条件:

I have a ColdFusion condition like this:

<cfif txtTaxFileNo neq "">
    <script>
        alert("NPWP Already Exist");
        history.back();
    </script>
    <cfabort>
</cfif>

假定txtTaxFileNo在上一页中的值为"123".如何清空txtTaxFileNo字段?我已经尝试过了:

Assume txtTaxFileNo has a value of "123" in the previous page. How can I empty the txtTaxFileNo field? I already tried this:

<cfif txtTaxFileNo neq "">
    <script>
        alert("#JSStringFormat('NPWP Already Exist')#");
        history.back();
        txtTaxFileNo.value = "";
    </script>
    <cfabort>
</cfif>

但是,前一页上的文本字段不为空.它的值仍为"123".预先感谢.

However, the textfield on the previous page is not empty. It still has a value of "123". Thanks in advance.

推荐答案

请勿使用history.back(),因为那样可以恢复表单状态.如果要加载新页面,只需加载新页面即可.

Don't usehistory.back() because that restores form state. If you want to load a fresh page, just load a fresh page.

<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()文档

See window.location.reload() docs on MDN.

这篇关于如何清除history.back()上的文本字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 22:20