Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get input value to modal box jquery UI

<div id="befor-box">
   <form id="newsletter-form" name="newsletter-form" action="/sub/" method="post">{% csrf_token %}
      <input name="email" type="text" value="Enter your Email here" class="text"/> 
      <input class="submit" onclick="showDialog();" value="Subscribe!" />
   </form>
</div>

How to get EMAIL value from:

<input name="email" type="text" value="Enter your Email here" class="text"/>

to:

<input name="email" type="text" value="" class="text"/>

from here:

<div id="dialog-modal" style="display:none;">
   <form name="newsletter-form" action="/sub/" method="post">
      <input name="email" type="text" value="" class="text"/>
      <input name="fname" type="text" value="First name" class="text"/>
      <input name="lname" type="text" value="Last name" class="text"/>
      <input type="submit" class="submit" value="Subscribe!" />
   </form>
</div>
<script type="text/javascript">
   function showDialog()
   {
   $( "#dialog-modal" ).dialog({


   });
   }
</script>
like image 307
Emanuel Avatar asked Mar 18 '13 09:03

Emanuel


People also ask

How do I get the value from modal popup?

If user click the hyperlink <a>See Milk</a> from the primary form, then will showing a JQuery Modal Dialog. Then if the option list are selected from the Modal Dialog & click Submit, it should closing the Modal Dialog & showing the value on the input type at primary form.

What is the method used to get value from input box?

Answer: Use the jQuery val() Method You can simply use the jQuery val() method to get the value in an input text box.

What is jQuery ui dialog?

The jQuery UI dialog method is used to create a basic dialog window which is positioned into the viewport and protected from page content. It has a title bar and a content area, and can be moved, resized and closed with the 'x' icon by default.


1 Answers

use open event of dialog which is called whn dialog opens... so replace the value there..

$( "#dialog-modal" ).dialog({
 open: function( event, ui ) {
     var boxInput=$("#befor-box").find('input[name="email"]').val(); //get the value..
     $("#dialog-modal").find('input[name="email"]').val(boxInput); //set the valu

 }
});
like image 188
bipen Avatar answered Sep 21 '22 08:09

bipen