提交表单后,如何清除整个页面,如何清除之前的文本字段值 [英] How do i clear the previous text field value after submitting the form with out refreshing the entire page

查看:302
本文介绍了提交表单后,如何清除整个页面,如何清除之前的文本字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 javascript html 制作一个包含文本字段,按钮的表单的Web应用程序。当我在该文本字段中输入数字并通过单击该按钮进行提交时,将动态生成文本区域。一旦我的表单被提交了一些文本区域被创建,但是如果我不满意现有的文本区域,那么我再次输入一些值刷新页面。但是之前输入的文本字段值通常会显示页面上现有文本区域下方的新文本区域。

I am doing a web application using javascript and html that has a form containing a text field, button. When i enter a number in that text field and submit by clicking on that button, text areas are generated dynamically. Once my form is submitted some text areas are created but if i am not satisfied with existing text areas then again i enter some value with out refreshing page. But the text field value entered previously prevails showing the new text areas below the existing text areas on the page.

那么,如何清除页面刷新的值,我该如何清除它。

So, how do i clear the value with out refreshing the page.

<div>
    <html>
     <input type="text" name = "numquest" id ="numquest" value="" size="5" style="" disabled>
     <input type="button" value="submit" onclick="getFields();">
</div>
    </html>

    <javascript>
      var num_q=document.getElementById('numquest').value;
     //code for dynamic creation
    </javascript>


推荐答案

您可以将元素的值设置为空

You can set the value of the element to blank

document.getElementById('elementId').value='';

这篇关于提交表单后,如何清除整个页面,如何清除之前的文本字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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