我怎样才能使用PHP窗体的重置按钮? [英] How can I use a reset button for php form?

查看:225
本文介绍了我怎样才能使用PHP窗体的重置按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我正在使用PHP处理的表单。用户提交之前,重置按钮的作品。但是当他们提交和页面重新加载(我已经根据$ _POST值使表单域变得粘滞)重置不起作用。我该如何解决这个问题?
编辑:
例如,表单上的复选框:

I've got a form that I'm handling with PHP. Before the user submits it, the Reset button works. But when they submit and the page reloads (I've made the form fields sticky based on the $_POST values) the reset doesn't work. How can I fix that? For example, a checkbox on the form:

 <input type="checkbox"  <?php if (isset($_POST['cb12'])){echo 'checked="checked"';} ?> name="cb12" tabindex="34" id=cb value="Education">

和HTML:

<tr>
          <td colspan="5" valign="top" class="addit" ><div class="sectionbreak topsp" >
              <input type="hidden" name="failure" value="failure.html" >
              <p>
                <input type="submit" name="Submit" value="Submit" tabindex="49">
                Sends your application by email to The Boggs</p>
              <p>
                <input type="reset" name="Reset" value="Reset" tabindex="50">
                Clears all the fields</p>
            </div></td>
        </tr>

编辑:
最后,我只是隐藏了按钮,如果表单已被提交(但不完整)。也许没有人会注意到。

In the end, I just hid the button if the form has been submitted (but isn't complete). Maybe no one will notice.

推荐答案

我刚刚度过了这个确切的事情,请参阅我的前一个问题&难以置信的有用答案

I've just been through this exact thing, see my previous question & the incredible helpful answers.

最后我不得不手动重置PHP中的值。

In the end I had to do a manual reset of the values in PHP.

编辑:对于你而言,你看起来并不像我一样填充基于$ _POST而不是$ _SESSION的表单值,这与你的情况不太一样。在这种情况下,请参阅我通过上述链接接受的答案。

Not quite the same scenario for you as you seem to be populating the form values based on $_POST rather than $_SESSION as I did. In which case, see the answer I accepted via the link above.

这篇关于我怎样才能使用PHP窗体的重置按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆