how to create a popup that returns data to the parent page
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
-
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
-
<title>Nieuwe pagina 1</title>
-
<script type="text/javascript">
-
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">
-
</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
-
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: 3% [?]
automatically resize iframe height depending on content
You can use this javascript function to resize the height of your iframe depending on the size of your parent page.
-
<script language="JavaScript">
-
function iFrameHeight() {
-
if(document.getElementById && !(document.all)) {
-
h = document.getElementById('main').contentDocument.body.scrollHeight;
-
document.getElementById('main').style.height = h + 100;
-
}
-
else if(document.all) {
-
h = document.frames('main').document.body.scrollHeight;
-
document.all.main.style.height = h + 100;
-
}
-
}
-
</script>
Popularity: 35% [?]
Setting a maxlenght to a textarea using javascript
If you want to limit the number of characters people can type in a textarea object. U should use a javascript because there is no such "maxlength" attribite as with a "normal" textbox.In the code below i use a small textbox (txtCounter) near the textarea to show the remaining characters.
onkeydown="EditCounter(frmYourForm,500)" onkeyup="EditCounter(frmYourForm,500)"
this is the javascript function
function EditCounter(myform, MaxChar){
var elements = document.getElementsByTagName('textarea');
if (elements[0].value.length >= MaxChar){
elements[0].value = String(elements[0].value).substring(0,MaxChar)
myform.txtCounter.value =MaxChar - elements[0].value.length ;
}else{
myform.txtCounter.value = MaxChar - elements[0].value.length ;
}
}

Popularity: 2% [?]
Calling a Vbscript msgbox using Javascript
Javascript just offers a simple alert box without any customisation. With the code below u can call a VBscript function from javascript witch makes it possible to create your own alert box with or without an icon.
Javascript function
NS4 = (document.layers);
IE4 = (document.all);
ver4 = (NS4 || IE4);function newAlert(title,mess,icon,mods) {
(IE4) ? makeMsgBox(title,mess,icon,0,0,mods) : alert(mess);
}
VBScript function
Function makeMsgBox(tit,mess,icons,buts,defs,mods)
butVal = buts + (icons*16) + (defs*256) + (mods*4096)
makeMsgBox = MsgBox(mess,butVal,tit)
End Function
Call the new alert box
newAlert("title","msg",0,0);
Popularity: 2% [?]


