如何清除已输入的输入文本值? [英] How to clear the input text value already entered ?

查看:95
本文介绍了如何清除已输入的输入文本值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,用户单击按钮以显示模态,然后填写模态上的表单,当他们单击模态上的保存时,在模式中输入的数据将显示在表单中。我想显示,当用户再次点击ADDPOSITION时,已经输入的文字应该被清除,并且不能更改以前保存的文字。



我尝试过:



< form name =stuff> 
<! - 按钮触发模式 - >
< button class =btn btn-primarydata-toggle =modaldata-target =#myModal>
添加头寸
< / button>

<! - 模态 - >
< div class =modal fadeid =myModaltabindex = - 1role =dialogaria-labelledby =myModalLabelaria-hidden =false>
< div class =modal-dialog>
< div class =modal-content>
< div class =modal-header>
< button type =buttonclass =closedata-dismiss =modalaria-hidden =false>
×
< / button>
< h3 class =modal-titleid =myModalLabel> add Position< / h3>
< / div>
< div class =modal-body>
< form name =modal-formclass =form-horizo​​ntal>
<! - 形式的东西在这里 - >
< input type =textname =job_titlevalue =/>
< input type =textname =fromvalue =/> - < input type =textname =tovalue =/> < input type =textname =total experiencevalue =/>
< input type =textname =industriesvalue =/>
< / form>
< / div>
< div class =modal-footer>
< button type =buttonclass =btn btn-defaultdata-dismiss =modal>
关闭
< / button>
< button type =buttontype =submitclass =btn btn-primaryid =savedata-dismiss =modal>
保存
< / button>
< / div>
< / div><! - /.modal-content - >
< / div><! - /.modal-dialog - >
< / div><! - /.modal - >

<! - 在模态上输入保存按钮数据后,即 - >>
< input type =textdisabled name =job_title []value =Software Developer/>
< input type =textdisabled name =from []value =November 2013​​/> - < input type =textdisabled name =to []value =present/> < input type =textdisabled name =total experience []value =2 months/>
< input type =textdisabled name =industries []value =IT/>
< / form>







javascript:

$('#save')。click(function(){

$(input [name ='job_title []'])。val($(input [name ='job_title' ])。val());

$(input [name ='from []'])。val($(input [name ='from'])。val ());

$(input [name ='to []'])。value($(input [name ='to'])。val());

$(input [name ='total experience []'])。val($(input [name ='total experience'])。val());

$(input [name ='industries []'])。val($(input [name ='industries'])。val());

} );

解决方案

('#save')。click(function(){


(输入[name ='job_title []'])。val(


(input [name ='job_title'])。val());

First the user clicks a button to make the modal appear, they then fill out form that is on the modal, and when they click save on the modal, the data entered on the modal displays in the form. i want to show , when user again clicks the ADDPOSITION , already entered text should be cleared and cannot be changed previous saved text.

What I have tried:

<form name="stuff">
<!-- Button trigger modal -->
<button class="btn btn-primary" data-toggle="modal" data-target="#myModal">
    add position
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="false">
                ×
            </button>
            <h3 class="modal-title" id="myModalLabel">add Position</h3>
        </div>
        <div class="modal-body">
            <form name="modal-form" class="form-horizontal">
                <!-- form stuff goes here -->
                 <input type="text"  name="job_title" value="" />
     <input type="text"  name="from" value="" />  – <input type="text" name="to" value="" /> <input type="text"  name="total experience" value="" /> 
     <input type="text"  name="industries" value="" /> 
            </form>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">
                Close
            </button>
            <button type="button" type="submit" class="btn btn-primary" id="save" data-dismiss="modal">
                Save
            </button>
        </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <!-- after save button data entered on modal goes here i.e. -->
     <input type="text" disabled name="job_title[]" value="Software Developer" />
     <input type="text" disabled name="from[]" value="November 2013" />  – <input type="text" disabled name="to[]" value="present" /> <input type="text" disabled name="total experience[]" value="2 months" /> 
     <input type="text" disabled name="industries[]" value="IT" /> 
</form>




javascript:
$('#save').click(function() {
$( "input[name='job_title[]']" ).val($("input[name='job_title']").val());
$( "input[name='from[]']" ).val($("input[name='from']").val());
$( "input[name='to[]']" ).val($("input[name='to']").val());
$( "input[name='total experience[]']" ).val($("input[name='total experience']").val());
$( "input[name='industries[]']" ).val($("input[name='industries']").val());
});

解决方案

('#save').click(function() {


( "input[name='job_title[]']" ).val(


("input[name='job_title']").val());


这篇关于如何清除已输入的输入文本值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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