Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Child window updating parent window 1

Status
Not open for further replies.

picobello

Programmer
Jan 23, 2006
7
DE
Dear Friends (and saviors)
I am not a programmer but using dreamweaver MX I am able to create some small application. I have written a blog application and in the cms portion of it, I have use just a regular text box to enter my message. Now, I have found a RT editor which I would like to implement into my application. Here is the situation. I have a page, named editor.asp in which I have all my blog entry field. One of them being "Message". I have also a link on that page, that opens a child window with the RT editor. Now, I want to be able to enter the content there and on submission have the html put into my "Message" textbox which I than write along with other fields into my database.

Here is are the codes

Parent page

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Total Quality Assurance</title>
<link href="/MainStyles.css" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE="JavaScript"><!--
function CreateWindow1() {
ChildWindow=window.open("rte/demo.asp","RTE","toolbar=no,width=600,height=500,directories=no,status=no,scrollbars=auto,resizable=no,border=0,menubar=no")
} // -->
</SCRIPT>
</head>
<body>

<table width="740" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" style="border-collapse: collapse">
<tr>
<td bgcolor="#3B465A"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#FF6600">
<td colspan="2"><img src="/images/1X1.gif" width="1" height="2"></td>
</tr>
<tr bgcolor="#000000">
<td colspan="2"><img src="/images/1X1.gif" width="1" height="1"></td>
</tr>
<tr>
<td valign="top" bgcolor="#626B78"><img src="/images/logo.gif" width="300" height="100"></td>
<td rowspan="2" valign="top"><img src="/images/TopRight.gif" width="439" height="200"></td>
</tr>
<tr>
<td valign="top" bgcolor="#626B78"><!--#include virtual="mSection.htm"--></td>
</tr>
<tr>
<td width="300" valign="top" bgcolor="#3B465A"><!--#include virtual="bSection.htm"--></td>
<td width="63%" valign="top" bgcolor="#FF6600"><table width="100%" border="0" cellspacing="6" cellpadding="6">
<tr>
<td><form action="editor.asp" method="get" name="MessageForm" id="MessageForm">
<textarea name="Message" cols="35" rows="5" id="Message"></textarea>
<a href="javascript:ChildWindow=CreateWindow1()">demo</a></p>
</form></td>
</tr>
</table></td>
</tr>
<tr bgcolor="#596271">
<td colspan="2"><!--#include virtual="fSection.htm"--></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>

and here is the Child Page

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>Cross-Browser Rich Text Editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="JavaScript" type="text/javascript" src="lang/en.js"></script>
<script language="JavaScript" type="text/javascript" src="richtext_compressed.js"></script>
<script language="JavaScript" type="text/javascript" src="html2xhtml_compressed.js"></script>
</head><body>
<form name="RTEDemo" action="../editor.asp" method="post" onsubmit="return submitForm();">
<script language="JavaScript" type="text/javascript">
<!--
function submitForm() {
updateRTE('rte1');
//updateRTEs();
document.outputform.outputfield.value = document.RTEDemo.rte1.value
document.outputform.submit()
//window.close();
}

//Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML)
initRTE("images/", "", "", true);
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
//Usage: writeRichText(fieldname, html, css_override, width, height, buttons, readOnly, fullscreen)
writeRichText('rte1','<b>Your Entry Here</b>', '', 580, 300, true, false, false);
//-->
</script>
<p><input type="submit" name="submit" value="Submit"></p>
</form>
<form action="../editor.asp" method="Post" name="outputform" id="outputform">
<input name="outputfield" type="text" id="outputfield" value="" size="65">
</form>
</body></html>

I have made an extra form&filed (outputform&outputfield) whcih I would like to have submited into the "message" field in the parent page.

any help would be highly appreciated
 
Start with this?
[tt]
function submitForm() {
updateRTE('rte1');
//updateRTEs();
document.outputform.outputfield.value = document.RTEDemo.rte1.value
[blue]window.opener.document.MessageForm.Message.value+="\n"+document.RTEDemo.rte1.value;[/blue]
document.outputform.submit()
//window.close();
}
[/tt]
 
tsuji,
thank you VEEEEEEERY much. For writing back to the parent windown, this code did the job with your help.

<script language="JavaScript" type="text/javascript">
<!--
function submitForm() {
updateRTE('rte1');
//updateRTEs();
window.opener.document.getElementById("Message").value = document.RTEDemo.rte1.value
window.close();
}

//Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML)
initRTE("images/", "", "", true);
//-->
</script>

Now, on another page (editing the content in db), I have the same situation, now I want to have the htm that is in the Message window, populated in the RT editor. Could I just use this:

<script language="JavaScript" type="text/javascript">
<!--
function submitForm() {
updateRTE('rte1');
//updateRTEs();
window.opener.document.getElementById("Message").value = document.RTEDemo.rte1.value
window.close();
}
//Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML)
initRTE("images/", "", "", true);
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
//Usage: writeRichText(fieldname, html, css_override, width, height, buttons, readOnly, fullscreen)
var sContent = window.opener.document.form1.Message.value+;
writeRichText('rte1','<%=sContent%>', '', 580, 300, true, false, false);
//-->
</script>

I did try this since it was my assumption, but that doesn't work. Any further ideas?

Again, Thank you very much with you help the main part is working.
 
Is it then not this? and I probably miss something.
[tt]
var sContent = window.opener.document.[red]MessageForm[/red].Message.value;
writeRichText('rte1',sContent+'<%=sContent%>', '', 580, 300, true, false, false);
[/tt]
I probably miss something because <%=sContent%> is server-side info to serve to the child window's page and bare sContent is the client-side parent content at serving time (reading probably has less timing issue then read-write). That is why the odd looking [tt]sContent+'<%=sContent%>'[/tt]. And I do not know writeRichText function which is probably scripted in some .js file.
 
YESSSSSSSS
Dear tsuji, Thank you soooooooo very much. I did the job. Can't thank you enough for you help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top