Click here to Skip to main content
15,881,625 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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());
});
Posted
Updated 7-Feb-18 2:48am
v2
Comments
F-ES Sitecore 7-Feb-18 7:37am    
What's your question?
OriginalGriff 7-Feb-18 7:47am    
"I identifies the problem, understands its nature and its component parts and the relation between them"
Excellent. That should help you a lot.
The problem is, we have no idea what problem you are having: what does that do that you didn't expect, or not do that you did? Where are you stuck? What help do you need?

Use the "Improve question" widget to edit your question and provide better information.
Murali Gowda 7-Feb-18 7:57am    
Just clear the textbox values at the end of click event.
$('#save').click(function() {
...//existing code
$("input[name='job_title']").val("");
$("input[name='from']").val("");
$("input[name='to']").val("");
$("input[name='total experience']").val("");
$("input[name='industries']").val("");
});

1 solution

In the "close modal" event handler clear all the inputs. Which event? Depends on which modal you're using. You could target the button, but your controls will not be empty if user clicks on the upper right X or somewhere on the screen outside of the modal.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900