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:
-
-
-
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
-
-
-
function createpopup(){
-
var wind1=null;
-
var tmp=null;
-
wind1 = window.open('popup.html', 'displayWindow', 'width=400,height=300,status=no,toolbar=no,menubar =no,scrollbars=1');
-
}
-
function getValues(){
-
document.forms["frmform"].elements["txtmail"].value = tmp;
-
}
-
</script>
-
</head>
-
-
-
<form action="#" name="frmform" method="get">
-
<input type="text" name="txtmail" value="" /><button onclick='createpopup();' name ="cmdpopup"/>
-
</form>
-
</body>
-
-
</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:
-
-
-
-
function filltextfield(f){
-
var text=f.txttext.value;
-
window.opener.tmp=text;
-
window.opener.getValues();
-
window.close();
-
}
-
</script>
-
</head>
-
-
<form action='#' name='myform' action='post'>
-
-
<INPUT type='button' value='save' onclick='javascript:filltextfield(this.form);'>
-
<INPUT type='button' value='cancel' onclick='javascript:window.close();'>
-
</form>
-
</body>
-
</html>
Popularity: 8% [?]
RSS feed for comments on this post · TrackBack URI
Leave a reply