Open screen by clicking on input and returning written data [closed]

-3

I need to click on a text type input to see a screen where I can enter text and when I click on an "Accept" button, I return the written data and put it in the original input.

For example:

  • Input1 when the click event is executed when a modal is opened.

The modal has a input2 where the user can write (states of Mexico for example) and with an "Accept" button close this screen and states written in input2 are written in input1 .

    
asked by Agus Olivera 19.12.2017 в 20:03
source

1 answer

1

For what you need you can use this library alertifyjs I hope you help greetings.

when doing click we execute the prompt and then when we accept it we add the value with $("#input1").val(value)

$("#input1").click(function(){
 alertify.prompt( 'Prompt Title', 'Prompt Message', 'Prompt Value'
               , function(evt, value) { 
               alertify.success('You entered: ' + value) 
               $("#input1").val(value) 
               }
               , function() { 
               alertify.error('Cancel') 
               });

})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/[email protected]/build/alertify.min.js"></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/[email protected]/build/css/alertify.min.css"/>
<input id="input1" type="text" name="" value="">
    
answered by 19.12.2017 / 20:24
source