Click to See Complete Forum and Search --> : Cannot populate diary with javascript function...


Rashar
04-20-2004, 08:31 AM
Hi, not sure if my issue is with the javascript but i'll ask...

I'm trying to populate notes from one text area to another. I have it working from the popup window where if notes are entered, and update is selected, it populates on my other form...but the other way around does not work...any help would be greatly appreciated. Here is the code in it's entirety.

**************************************************

<!-- Notes section -->

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>test form</title>
<script language="JavaScript">

function transfer(str){
if (opener && !opener.closed){
opener.document.FrontPage_Form2.Notes.value=str;
}
}

</script>

</head>
<!--#include file="../_private/config.inc"-->
<body bgcolor="#C0C0C0">

<h2 align="center">Populate Notes</h2>

<form method="POST" action="../test/notes.asp" onsubmit="return FrontPage_Form1_Validator(this)" name="FrontPage_Form1">
<br>
<div align="center">
<center>
<TABLE border="0" cellspacing="0" width="817" style="border-collapse: collapse" cellpadding="0">

<tr>
<td width="802" height="21" valign="top">
<p align="right">&nbsp;<p align="left">



<font color="#FF0000">*</font> Problem Notes:
<a href="#null" onclick="popit=open('popup_notes.asp','pop','top=280,left=390,width=750,height=600,scrollbars=yes,resizable=y es' ); popit.focus(); transfer(document.FrontPage_Form1.Notes.value);">
<img border="0" src="../remedy/diary.jpg" width="25" height="22" alt="Diary Editor"></a>
<br>
<!--webbot bot="Validation" s-display-name="Notes" b-value-required="TRUE" i-maximum-length="4000" --><textarea rows="8" name="Notes" cols="53"></textarea></td>
</tr>
</table>
</center>
</div>
</hr>
<p align="center"><input type="submit" value="Save" name="Submit"><input type="reset" value="Reset" name="B2"></p>

</form>

</body>

</html>


**************************************************


<!-- PopUp Window section -->

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

</head>
<script language="javascript">

function transfer(str){
if (opener && !opener.closed){
opener.document.FrontPage_Form1.Notes.value=str;
}
}
</script>
<body onLOAD="transfer(document.FrontPage_Form2.Notes.value)" bgcolor="#C0C0C0">



<form name="FrontPage_Form2">
<P align="center">
<textarea rows="31" name="Notes" cols="81"></textarea>
<BR>
<P align="center">
<input type="button" value="Update" onclick="transfer(document.FrontPage_Form2.Notes.value); window.close()">&nbsp;&nbsp;&nbsp;
</form>
</body>

</html>

requestcode
04-20-2004, 08:49 AM
I believe you want to change the function to this:
function transfer(str){
if (popit && !popit.closed){
popit.document.FrontPage_Form2.Notes.value=str;
}
}

When you referenct the term "opener" you are referencing the window that opened a child window. In your code to open the popup you gave it a variable name of "popit" so that is what you want to reference to update a form field in the popup window. Also I would change your code to open the popup to this:

onclick="popit=window.open('popup_notes. asp','pop','top=280,left=390,width=750,height=600,
scrollbars=yes,resizable=yes' ); popit.focus()"

"window.open" is the correct way to do it. Good Luck.

Rashar
04-20-2004, 09:51 AM
Hey Requestcode...thanks for your help...

At first I was getting popit was undefined, but then I passed opener to it... When I click on the book image to pop up a window, no notes are displayed...no errors, but no notes. Its as if the value some how is being lost when the pop up window event occurs...

But thanks for your assistance.

Best regards,

Rashar