dongque4778 2009-04-02 19:52
浏览 372
已采纳

如何使用php表单的重置按钮?

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? EDIT: 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">

And the 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>

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

  • 写回答

5条回答 默认 最新

  • douduan6731 2009-04-02 21:53
    关注

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

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

    EDIT: 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
  • ¥15 QTOF MSE数据分析
  • ¥15 平板录音机录音问题解决