Dalam contoh berikut ini, kita akan membuka sebuah pop up windows, input sebuah nilai dan mengirimkan nilai yang di inputkan dari pop up windows ke form utama.
example1.html
<html>
<script LANGUAGE="JavaScript">
function openChild(file,window) {
childWindow=open(file,window,'resizable=no,width=200,height=400');
if (childWindow.opener == null) childWindow.opener = self;
}
</script>
<body>
<form NAME="parentForm">
<br /><input NAME="input1" TYPE="TEXT" VALUE=""/>
<br /><input NAME="input2" TYPE="TEXT" VALUE=""/>
<input TYPE="button" VALUE="Open child"
onClick="openChild('example2.html','Child')"/>
</form>
</body>
</html>
example2.html
<html>
<head>
<script LANGUAGE="JavaScript">
function updateParent() {
opener.document.parentForm.input1.value = document.childForm.cInput1.value;
opener.document.parentForm.input2.value = document.childForm.cInput2.value;
self.close();
return false;
}
</script>
</head>
<body>
<form NAME="childForm" onSubmit="return updateParent();">
<br /><input NAME="cInput1" TYPE="TEXT" VALUE=""/>
<br /><input NAME="cInput2" TYPE="TEXT" VALUE=""/>
<br /><input TYPE="SUBMIT" VALUE="Update"/>
</form>
</body>
</html>








4 Comments Received
May 15th, 2008 @7:13 am
kasih penjelasan dong
salam kenal
May 15th, 2008 @7:53 am
@petra
.
salam kenal juga.
sebenarnya agak ribet juga ngasih penjelasannya, plus lg malas
Tapi dari contoh diatas, kalo langsung dicoba bisa kelihatan nantinya
May 15th, 2008 @12:19 pm
Wah bagus juga penjelasannya zan, posting juga donk di belajarpemrograman.net
Pingback & Trackback
Leave A Reply