Forums

This topic is locked

Passing back Child Window textbox value to Parent

Posted 04 Jun 2005 10:59:28
1
has voted
04 Jun 2005 10:59:28 blake nanabil posted:
hello everyone!

i had a project that will add the value of a text box in the child
window to the list box in the parent window, would appreciate if anyone
could help me how to do this, any help would be highly appreciated,
below is my code:

PARENT WINDOW CODE
================

<HTML>
<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<!--

// pop-up window
function PopUp(PopUpUrl){
var ScreenWidth=window.screen.width;
var ScreenHeight=window.screen.height;
var movefromedge=0;
placementx=(ScreenWidth/2)-((310)/500);
placementy=(ScreenHeight/2)-((240+10)/6);
WinPop=window.open(PopUpUrl,"","width=310,height=240,toolbar=0,location=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,left="+placementx+",top="+placementy+",screenX="+placementx+",screenY="+placementy+",";
}
// -->
</SCRIPT>

</HEAD>

<BODY BGCOLOR="#E0EOFF">
<FONT FACE="sans-serif">
<!--

-->
<FORM NAME="MYFORM">
<CENTER>
<TABLE CELLPADDING="7" CELLSPACING="0" BORDER = "3" WIDTH="673" bgcolor="#FFFFFF">
<TR>
<TD>
</FONT>
<FONT FACE="Verdana">
<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0">
<TR>
<TD>
<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0">
<TR>
<TD WIDTH="36%" height="18" align="center">
<p align="center"><b>
<FONT FACE="Verdana" size="2">
Selected Recipients</FONT></b></TD>
</TR>
<TR>
<TD width="36%">
<p align="center">
<FONT FACE="sans-serif">
<SELECT NAME="PICKED" SIZE="9" MULTIPLE onChange="DoDeselectBlankLine(this.form.PICKED)" style="width: 240; height: 150">
<option value="0"></option>
</SELECT></FONT></TD>
</TR>
</TABLE>
</TD>
</TR>
</TR>
</TABLE>
<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0">
<TR>
<TD>
<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0">
<TR>
<TD HEIGHT="5" colspan="2">
</TD>
</TR>
<TR>
<td width="83%">
<FONT FACE="sans-serif">
<p align="center">
<p align="center">
 </FONT></td>
<td width="16%">
<FONT FACE="sans-serif">
<input type="button" name="button" value="Lunch Keypad" onclick="PopUp('pad.htm')" style="width: 99; height: 26; float: left"></FONT></td>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0">
<TR>
<TD HEIGHT="2">
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</CENTER>
</FORM>
</FONT>
</BODY>
</HTML>


CHILD WINDOW CODE
================

<html>

<head>
<title>Paging Keypad</title>
<SCRIPT language=JavaScript>

<!-- Begin keyapd script
var Memory = 0;
var Number1 = "";
var Number2 = "";
var NewNumber = "blank";
var opvalue = "";

function Display(displaynumber) {
document.keypad.answer.value = displaynumber;
}

function ClearKeypad() {
Number1 = "";
Number2 = "";
NewNumber = "blank";
Display("";
}

function Backspace(answer) {
answerlength = answer.length;
answer = answer.substring(0, answerlength - 1);
if (Number2 != "" {
Number2 = answer.toString();
Display(Number2);
} else {
Number1 = answer.toString();
Display(Number1);
}
}

function CheckNumber(answer) {
if(answer == "." {
Number = document.keypad.answer.value;
if(Number.indexOf("." != -1) {
answer = "";
}
}
if(NewNumber == "yes" {
Number2 += answer;
Display(Number2);
}
else {
if(NewNumber == "blank" {
Number1 = answer;
Number2 = "";
NewNumber = "no";
}
else {
Number1 += answer;
}
Display(Number1);
}
}

function SendInfo(){
var txtVal = document.keypad.answer.value;
var sel = window.opener.document.MYFORM.PICKED;
sel.options[sel.options.length] = new Option("answer","value";
window.opener.document.MYFORM.PICKED.value = txtVal;
}

function closeIt() {
close();
}
// Input numbers only
var isIE = document.all?true:false;
var isNS = document.layers?true:false;
function onlyDigits(e) {
var _ret = true;
if (isIE) {
if (window.event.keyCode < 46 || window.event.keyCode > 57) {
window.event.keyCode = 0;
_ret = false;
}
}
if (isNS) {
if (e.which < 46 || e.which > 57) {
e.which = 0;
_ret = false;
}
}
return (_ret);
}

// End keypad script -->
</SCRIPT>

</head>

<body>
<CENTER>
<FORM name=keypad>
<TABLE width=220 bgColor=#aaaaaa id="table1">
<TBODY>
<TR>
<TD>
<TABLE bgColor=#cccccc border=1 id="table2" width="213">
<TBODY>
<TR>
<TD>
<TABLE cellPadding=0 border=0 id="table3" width="243">
<TBODY>
<TR>
<TD bgColor=#000080>
<p align="center"><font face="Verdana" size="2"><B
style="COLOR: white">Paging Keypad</B></font></TD></TR>
<TR>
<TD>
<TABLE width="101%" border=0 id="table4">
<TBODY>
<TR>
<TD colSpan=3>
<p align="center">
<INPUT maxLength=30
onchange=CheckNumber(this.value) size=36
name=answer></TD></TR>
<TR>
<TD>
<INPUT class=blue onclick="CheckNumber('7'); return false;" type=button value=" 7 " name=pindot7 style="width: 84"></TD>
<TD width="27%">
<INPUT class=blue onclick="CheckNumber('8'); return false;" type=button value=" 8 " name=pindot8 style="width: 84; height:26"></TD>
<TD width="40%">
<INPUT class=blue onclick="CheckNumber('9'); return false;" type=button value=" 9 " name=pindot9 style="width: 84"></TD>
</TR>
<TR>
<TD width="14%">
<INPUT class=blue onclick="CheckNumber('4'); return false;" type=button value=" 4 " name=pindot4 style="width: 84"></TD>
<TD width="27%">
<INPUT class=blue onclick="CheckNumber('5'); return false;" type=button value=" 5 " name=pindot5 style="width: 84"></TD>
<TD width="40%">
<INPUT class=blue onclick="CheckNumber('6'); return false;" type=button value=" 6 " name=pindot6 style="width: 84"></TD>
</TR>
<TR>
<TD width="14%">
<INPUT class=blue onclick="CheckNumber('1'); return false;" type=button value=" 1 " name=pindot1 style="width: 84"></TD>
<TD width="27%">
<INPUT class=blue onclick="CheckNumber('2'); return false;" type=button value=" 2 " name=pindot2 style="width: 84"></TD>
<TD width="40%">
<INPUT class=blue onclick="CheckNumber('3'); return false;" type=button value=" 3 " name=pindot3 style="width: 84"></TD>
</TR>
<TR>
<TD width="14%" height="28">
<INPUT class=blue onclick="CheckNumber('0'); return false;" type=button value=" 0 " name=pindot0 style="width: 84"></TD>
<TD width="27%" height="28">
<INPUT class=red onclick="ClearKeypad(); return false;" type=reset value="Clear " name=C style="width: 84"></TD>
<TD width="40%" height="28">
<INPUT class=red onclick="Backspace(document.keypad.answer.value); return false;" type=button value=Backspace name=backspace style="width: 84; "></TD>
</TR>
<TR>
<TD width="56%" height="28" colspan="2">
<INPUT type=button value="Add to selected Recipient" name=btnAdd onclick="SendInfo()" style="width: 172; height: 26"></TD>
<TD width="40%" height="28">
<input type="button" value="Exit" name="btnExit" onClick="closeIt()" style="width: 84; height: 26"></TD>
</TR>
</TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></FORM>

<script>
if (isNS) document.captureEvents(Event.KEYPRESS);
document.onkeypress=onlyDigits;
</script>

</body>

</html>

Reply to this topic