In this code snippet i will show you how you can click a button after an input field wich creates a popup. This popup is actually a plain html page where you can enter data into a textarea. When the user is done editing text in the textarea, he can hit the save button and the value from the textarea is saved to the textfield on the main.html page.

main.html

HTML:
  1. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  2. <title>Nieuwe pagina 1</title>
  3.     <script type="text/javascript">
  4.         function createpopup(){
  5.             var wind1=null;
  6.             var tmp=null;
  7.             wind1 = window.open('popup.html', 'displayWindow', 'width=400,height=300,status=no,toolbar=no,menubar =no,scrollbars=1');
  8.         }
  9.         function getValues(){
  10.             document.forms["frmform"].elements["txtmail"].value = tmp;
  11.         }
  12.     </script>
  13. </head>
  14.  
  15. <form action="#" name="frmform" method="get">
  16. <input type="text"  name="txtmail" value="" /><button onclick='createpopup();' name ="cmdpopup"/>
  17. </form>
  18. </body>
  19.  
  20. </html>

When the user clicks ont the save button, the data in the textarea is send to a function on the main page that puts the data into the textfield
popup.html

HTML:
  1.     function filltextfield(f){
  2.         var text=f.txttext.value;
  3.         window.opener.tmp=text;
  4.         window.opener.getValues();
  5.         window.close();
  6.         }
  7. </script>
  8. </head>
  9. <form action='#' name='myform' action='post'>
  10. <TEXTAREA rows='2' cols='20' name='txttext'></TEXTAREA><br>
  11. <INPUT type='button' value='save' onclick='javascript:filltextfield(this.form);'>
  12. <INPUT type='button' value='cancel' onclick='javascript:window.close();'>
  13. </form>
  14. </body>
  15. </html>

Popularity: 8% [?]