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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms and objects and accessing those objects

Status
Not open for further replies.

cubicle4

Programmer
Jun 18, 2001
18
US
Hi all,

I have a window which contains a form and in the form contains an object I have created known as "MyContent1". From this object I can open a popup window. This popup contains a search form. At this time I am still able to call methods from the object on the parent window. However, if I perform a search (this is the purpose of the popup) which is a self-posting form and I try to call one of the object methods from the parent window I get nothing ( i mean it does nothing ). Also, if I try to see if that object exists using an alert it returns 'undefined'.

Why can I not access this object from the popup window after the form post?

TIA

Harold
 
Hi,

I have discontinued my efforts and went with a solution that already works, however would still like to resolve this as it adds greater functionality. The popup window code that I have include is the original. If you need more info then I would be glad to send you the templates that I was trying to use. Either way the javascript is the same in both instances. The only difference is that the original popup has no form post where as the new one did.

thx

This is the code from the parent window (less the .js files):

<script language=&quot;JavaScript1.2&quot;>
<!--

if (typeof eWebEditPro == &quot;object&quot;)
{
document.frmEdit.eWebEditProSubmitHandled=true;
eWebEditPro.create(&quot;MyContent1&quot;, 640, 500);
}

//-->
</script>

Here is the javascript code from the popup that accesses the object eWebEditPro[&quot;MyContent1&quot;]:
And btw, some of the code you see in here is tcl and storyserver, jicyww.

<html>
<head>
[INCLUDE LIBNAME &quot;CMA Stylesheet&quot;]
<title>Hyperlink</title>

<script language=&quot;JavaScript&quot;>
<!--
var objQuery = new Object();
var selectedText;
var selectedHTML;
var strQuery = location.search.substring(1);
var aryQuery = strQuery.split(&quot;&&quot;);
var pair = \[\];
for (var i = 0; i < aryQuery.length; i++)
{
pair = aryQuery\[i\].split(&quot;=&quot;);
if (pair.length == 2)
{
objQuery\[unescape(pair\[0\])\] = unescape(pair\[1\]);
}

}

/*if the a hyperlink in the eWebEditPro control has been highlighted then
display the selected hyperlink text in the &quot;Text&quot; text box, display its path in the &quot;Link&quot;
text box and display the quick link in the &quot;Quick Links&quot; list.
NOTE: External links must have the &quot; prefix otherwise these links will be
treated as internal links which causes the &quot;HTTP 404 Not Found&quot; error.
*/
function loadselectedtext() {
var testimage;
var thePath=&quot;&quot;;
selectedText = top.opener.eWebEditPro\[objQuery\[&quot;editorName&quot;\]\].getSelectedText();
selectedHTML = top.opener.eWebEditPro\[objQuery\[&quot;editorName&quot;\]\].getSelectedHTML();
testimage = selectedHTML.substring(0, 4);
if (testimage.toLowerCase() == &quot;<img&quot;){
document.frmHyperlinks.text2.value = selectedHTML;
}
else
{
document.frmHyperlinks.text2.value = selectedText;
tmpstr = selectedHTML.toLowerCase();
tmpstrEWP = selectedHTML;
//debug selected html value
//var htmlval_alert = tmpstr.substring( tmpstr.indexOf('&quot;')+1, tmpstr.lastIndexOf('&quot;') );
//alert(htmlval_alert);
if (tmpstrEWP.indexOf(&quot;<ewp>&quot;) == -1) {
if (tmpstr.indexOf(&quot;href&quot;)!= -1) {
if (tmpstr.indexOf(&quot;http&quot;) == -1) {
//get the path without the html tags for internal links
thePath = selectedHTML.substring( tmpstr.indexOf(&quot;/&quot;), tmpstr.lastIndexOf('&quot;') );
for (var i = 0; i < document.frmHyperlinks.hyperlinklist.length; i++) {
if (document.frmHyperlinks.hyperlinklist.options\[i\].value == thePath) {
document.frmHyperlinks.hyperlinklist.options\[i\].selected = true;
movelink();
break;
}
}

//get the target window
if (tmpstr.indexOf(&quot;target&quot;) != -1) {
tmpTarget = tmpstr.substring( tmpstr.lastIndexOf(&quot;=&quot;)+1, tmpstr.lastIndexOf('<') );
targetWin = tmpTarget.split(&quot;>&quot;);
for (var i = 0; i < document.frmHyperlinks.Target.length; i++) {
if (document.frmHyperlinks.Target.options\[i\].value == targetWin\[0\]) {
document.frmHyperlinks.Target.options\[i\].selected = true;
break;
}
}
}

} else {
//get the path without the html tags for external links
thePath = tmpstr.substring( tmpstr.indexOf(&quot;http&quot;), tmpstr.lastIndexOf('&quot;') );
document.frmHyperlinks.httpLink.value = thePath;

//get the target window
if (tmpstr.indexOf(&quot;target&quot;) != -1) {
tmpTarget = tmpstr.substring( tmpstr.indexOf(&quot;_&quot;), tmpstr.lastIndexOf('>') );
targetWin = tmpTarget.split(&quot;>&quot;);
for (var i = 0; i < document.frmHyperlinks.Target.length; i++) {
if (document.frmHyperlinks.Target.options\[i\].value == targetWin\[0\]) {
document.frmHyperlinks.Target.options\[i\].selected = true;
break;
}
}
}
}
}
} else {
thePath = tmpstrEWP.substring( tmpstr.indexOf('&quot;')+1, tmpstr.lastIndexOf('&quot;') );
document.frmHyperlinks.httpLink.value = thePath;
}
}
}

//trim leading and trailing spaces
function trim(strText) {
// this will get rid of leading spaces
while (strText.substring(0,1) == ' ')
strText = strText.substring(1, strText.length);

// this will get rid of trailing spaces
while (strText.substring(strText.length-1,strText.length) == ' ')
strText = strText.substring(0, strText.length-1);

return strText;
}


//display the path of the selected image in the &quot;Link&quot; text box
function movelink() {
var hyperlinkvalue;
var pastevalue;
hyperlinkvalue = document.frmHyperlinks.hyperlinklist.options\[document.frmHyperlinks.hyperlinklist.selectedIndex\].value;
if (hyperlinkvalue == &quot;&quot;) {
document.frmHyperlinks.httpLink.value = &quot; } else {
document.frmHyperlinks.httpLink.value = hyperlinkvalue;
}
}


//insert the select hyperlink into the eWebEditPro control
function inserthyperlink() {
if (top.opener.closed){
alert(&quot;Your hyperlink could not be inserted because the editor page has been closed.&quot;);
}
else if (document.frmHyperlinks.text2.value == ''){
alert(&quot;Your hyperlink text is blank and would create an empty link.&quot;);
}
else{
var hyperlinkvalue;
var pastevalue;
var targetvalue;
var targetvaluepaste

targetvalue = document.frmHyperlinks.Target.options\[document.frmHyperlinks.Target.selectedIndex\].value;
if (targetvalue == &quot;&quot;) {
targetvaluepaste = &quot;&quot;;
}
else {
targetvaluepaste = &quot;target=&quot; + targetvalue;
}

hyperlinkvalue = trim(document.frmHyperlinks.httpLink.value);
if (hyperlinkvalue.substring(0,7) == &quot; {
pastevalue = '<A HREF=&quot;' + hyperlinkvalue + '&quot; ' + targetvaluepaste +'>' + document.frmHyperlinks.text2.value + '</a>';
}
else {
if (document.frmHyperlinks.hyperlinklist.value != &quot;&quot;) {
hyperlinkvalue = '<ewp>'+ document.frmHyperlinks.hyperlinklist.value + '</ewp>';
//debugging -- //hyperlinkvalue = '<ewp>CID950-TTL' + document.frmHyperlinks.text2.value + '-PLMEPMO-GEOINF</ewp>';
pastevalue = '<a href=&quot;' + hyperlinkvalue + '&quot; ' + targetvaluepaste +'>' + document.frmHyperlinks.text2.value + '</a>';
} else {
hyperlinkvalue = '<ewp>'+ document.frmHyperlinks.httpLink.value + '</ewp>';
//debugging -- //hyperlinkvalue = '<ewp>CID950-TTL' + document.frmHyperlinks.text2.value + '-PLMEPMO-GEOINF</ewp>';
pastevalue = '<a href=&quot;' + hyperlinkvalue + '&quot; ' + targetvaluepaste +'>' + document.frmHyperlinks.text2.value + '</a>';
}
}
selectedHTML = top.opener.eWebEditPro\[objQuery\[&quot;editorName&quot;\]\].getSelectedHTML();
top.opener.eWebEditPro\[objQuery\[&quot;editorName&quot;\]\].pasteHTML(pastevalue);
self.close();
}

}


// opens new popup window for the preview of locale relationships
function srchLinkWin(sURL) {
var w = 750;
var h = 600;
//do not try to center, since opener is not centered
//var winl = (screen.width - w) / 2;
//var wint = (screen.height - (h * 3)) / 2;
var sFeatures = 'height='+h+',width='+w+',scrollbars=yes,toolbar=no,resizable=yes,status=no,name=Search'
sNewWindow = window.open(sURL,'HyperLinkList',sFeatures);
}


//-->
</script>
</head>
<body onload=&quot;JavaScript:self.focus()&quot;>

<form name=&quot;frmHyperlinks&quot;>
<table width=&quot;100%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;3&quot; align=&quot;center&quot; border=&quot;0&quot;>
<tr>
<td colspan=2 bgcolor=&quot;#DBDBB7&quot;>
<b>Select Hyperlink</b>
</td>
</tr>

<tr><td> </td></tr>

<tr>
<td>Link:</td>
<td><INPUT type=&quot;text&quot; name=&quot;httpLink&quot; size=&quot;60&quot; maxlength=&quot;1000&quot; value=&quot;</tr>
<tr>
<td>Text:</td>
<td><INPUT type=&quot;text&quot; name=&quot;text2&quot; size=&quot;60&quot; maxlength=&quot;1000&quot; value=&quot;&quot;></td>
</tr>
<tr>
<td>Target Frame:</td>
<td>
<select name=&quot;Target&quot;>
<option value=&quot;&quot;></option>
<option value=&quot;_blank&quot;>New Window (_blank)</option>
<option value=&quot;_self&quot;>Same Window (_self)</option>
<option value=&quot;_parent&quot;>Parent Window (_parent)</option>
<option value=&quot;_top&quot;>Browser Window (_top)</option>
</select>
</td>
</tr>
<tr>
<td>Quick Links: </td>
<td>
<!--- Hyperlink selection list --->


<select name=&quot;hyperlinklist&quot; size=&quot;1&quot; onchange=&quot;movelink()&quot;>
<option value=&quot;&quot;></option>
[FOREACH ROW IN [SHOW lContent] {
<option value=&quot;CID[string trim [FIELD cb_item_id]]-TTL[string trim [FIELD cntnt_title]]-PLM[string trim [FIELD cda_placements_val]]-GEO[string trim [FIELD geo_zone]]&quot;>[string trim [FIELD cb_item_id]] - [string trim [string range [FIELD cntnt_title] 0 50]]</option>
}]
</select>

</td>
</tr>
<tr>
<td colspan=&quot;2&quot; align=&quot;center&quot;><input type=&quot;button&quot; value=&quot;Create Link&quot; onClick=&quot;inserthyperlink();&quot;> <input type=&quot;button&quot; name=&quot;Cancel&quot; value=&quot;Cancel&quot; onclick=&quot;self.close()&quot;></td>
</tr>
</table>
</form>
<script language=&quot;JavaScript&quot;>
<!--
loadselectedtext();
//-->
</script>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top