KaviSuja
KaviSuja

Reputation: 450

Popup window get value and clear while close it

I have alert pop up window on dblclick of textbox. I have a text area inside pop up window, I want to store the value entered in popup window in temporary variable and close popup window. Is it possible to store the data temporary and also clear the data once popup window is closed by user. because for multiple textboxes have same alert window.

var opt = {
            autoOpen: false,
            modal: true,
            width: 350,
            height: 'auto',
            title: 'Comments'
        };

        $(function () {
            $("#Cmnts").dialog({
                autoOpen: false                
            });
        });
     $(document).ready(function () {
                    var theDialog = $("#Cmnts").dialog(opt);
                    $("input[type='text']").on("dblclick", function () {
                        $('#Cmnts').dialog('open');
             });
        });

    <div id="Cmnts" style="display:none;">
            <textarea name="Cmnts" id="CmntsTxt" rows="5" cols="30"></textarea>
     </div>

can anyone help me to solve this Thanks in advance..

Upvotes: 1

Views: 1450

Answers (1)

rrk
rrk

Reputation: 15846

Add the below code in ready

$("#Cmnts").on('dialogclose', function(event) {
    $("#dialogValue").val($('#CmntsTxt').val())
    $('#CmntsTxt').val('');
});

Add HTML

<input type="hidden" id="dialogValue">

Here is the demo

Upvotes: 1

Related Questions