By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

get dynamic formname and return value to opener

P: n/a
Hi,

I have 6 forms being generated using coldFusion, they are named
special1, special2 special3 and so on.. in these forms I have a link to
open a new window.

I am trying to pickup the formname passed along to the new window.. the
window opener function is:

<SCRIPT LANGUAGE = "JavaScript">
<!--

function newupload()
{

var
newWind=window.open(imageupload.cfm,'remote','widt h=450,height=430,scrollbars=yes,status=yes');
if (newWind.opener == null)
{ newWind.opener = window; }

}

//-->
</SCRIPT>

the caller: <A HREF = "javascript:newupload('#formname#',
'special_image')">Upload New Image</A>

... this is working, then in the new window after some processing I want
to return a value to the opener..

this is what I need but I dont know how to get it..

window.opener.document."Formname".value

after looking around this is what I've been trying
<SCRIPT LANGUAGE="JavaScript">
<!--
function setimagename(iName)
{

var argstr = location.search.substring(1, location.search.length)
var args = argstr.split('?');
var ci = unescape(args[0]);
document.write(ci); // prints it in the HTML

/*opener.document.Special1.special_image.value=iNam e;*/

/*close();*/

}
//-->
</SCRIPT>
but it doesn't work.. no error just doesn't work (using ie 6)
Any Ideas welcome..
Dave

Feb 2 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hello Dave,

Can you give an HTML version of the page, it would be easier to assist if
the problem is seen.

--
Elias
<dr****@canoemail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi,

I have 6 forms being generated using coldFusion, they are named
special1, special2 special3 and so on.. in these forms I have a link to
open a new window.

I am trying to pickup the formname passed along to the new window.. the
window opener function is:

<SCRIPT LANGUAGE = "JavaScript">
<!--

function newupload()
{

var
newWind=window.open(imageupload.cfm,'remote','widt h=450,height=430,scrollbars=yes,status=yes');
if (newWind.opener == null)
{ newWind.opener = window; }

}

//-->
</SCRIPT>

the caller: <A HREF = "javascript:newupload('#formname#',
'special_image')">Upload New Image</A>

.. this is working, then in the new window after some processing I want
to return a value to the opener..

this is what I need but I dont know how to get it..

window.opener.document."Formname".value

after looking around this is what I've been trying
<SCRIPT LANGUAGE="JavaScript">
<!--
function setimagename(iName)
{

var argstr = location.search.substring(1, location.search.length)
var args = argstr.split('?');
var ci = unescape(args[0]);
document.write(ci); // prints it in the HTML

/*opener.document.Special1.special_image.value=iNam e;*/

/*close();*/

}
//-->
</SCRIPT>
but it doesn't work.. no error just doesn't work (using ie 6)
Any Ideas welcome..
Dave

Feb 2 '06 #2

P: n/a
dr****@canoemail.com wrote:
Hi,

I have 6 forms being generated using coldFusion, they are named
special1, special2 special3 and so on.. in these forms I have a link to
open a new window.

I am trying to pickup the formname passed along to the new window.. the
window opener function is:

<SCRIPT LANGUAGE = "JavaScript">
<!--

function newupload()
{

var
newWind=window.open(imageupload.cfm,'remote','widt h=450,height=430,scrollbars=yes,status=yes');
if (newWind.opener == null)
{ newWind.opener = window; }

}

//-->
</SCRIPT>

the caller: <A HREF = "javascript:newupload('#formname#',
'special_image')">Upload New Image</A>

.. this is working, then in the new window after some processing I want
to return a value to the opener..

this is what I need but I dont know how to get it..

window.opener.document."Formname".value
function getFormNamesFromOpener(){
var f=window.opener.document.forms,ff=f.length,ARR=[];
while(ff--) {ARR.push(f[ff].name}
return ARR;
}
alert(getFormNamesFromOpener().join("/");


after looking around this is what I've been trying
<SCRIPT LANGUAGE="JavaScript">
<!--
function setimagename(iName)
{

var argstr = location.search.substring(1, location.search.length)
var args = argstr.split('?');
var ci = unescape(args[0]);
document.write(ci); // prints it in the HTML
I don't know what you're trying to do here but the following is equivalent:

function setimagename(iName){
document.write(unescape(location.search.substring( 1));
}

Mick

/*opener.document.Special1.special_image.value=iNam e;*/

/*close();*/

}
//-->
</SCRIPT>
but it doesn't work.. no error just doesn't work (using ie 6)
Any Ideas welcome..
Dave

Feb 2 '06 #3

P: n/a
sorry about the size but here is the page with the forms.. only 2 in
this example.. I'm trying to pass the formname in the urlstring to try
and acess..

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Tyendinaga Computers - Virtual Office</title>
<link rel="STYLESHEET" type="text/css" href="../tc.css">

<SCRIPT LANGUAGE = "JavaScript">
<!--

// 'imageupload.cfm?form='function to load the upload window.
function newupload()
{

theURL = "imageupload.cfm?id=" + special1;
var
newWind=window.open(theURL,'remote','width=450,hei ght=430,scrollbars=yes,status=yes');
if (newWind.opener == null)
{ newWind.opener = window; }

}

//-->
</SCRIPT>
</head>

<body bgcolor="#ffffff" leftmargin="0" marginwidth="0" rightmargin="0">
<table cellpadding="0" cellspacing="0" border="1" width="100%">
<tr>
<td align="center"><img src="images/logo.gif" width="329" height="64"
alt="" border="0"><br><img src="images/spacer.gif" width="1"
height="10" alt="" border="0"></td>
</tr>
<tr>
<td background="images/bg_blue.gif"><img src="images/spacer.gif"
width="1" height="1" alt="" border="0"></td>
</tr>
<tr>
<td background="images/bg_red.gif"><img src="images/spacer.gif"
width="10" height="1" alt="" border="0"><img src="images/vo.gif"
width="157" height="31" alt="" border="0"></td>
</tr>
<tr>
<td bgcolor="#ffffff"><img src="images/spacer.gif" width="1"
height="1" alt="" border="0"></td>
</tr>
<tr>
<td background="images/bg_blue.gif" height="350" valign="top"><img
src="images/spacer.gif" width="1" height="1" alt="" border="0"><br>
<p>&nbsp;&nbsp;&nbsp;&nbsp;<a href="index.htm" class="vo">Main Menu</a>
<table cellpadding="3" cellspacing="0" border="0" align="center">
<tr>
<td class="vohdr" colspan="2">Edit Specials<br><br></td>
</tr>
<tr>
<td colspan="2" class="vohdr"><b>Information Below will appear on
the <a href="../comp_special.cfm" class="vohdr">Specials
Page</a></b></td>
</tr>
<tr>
<td bgcolor="#F7F3F3" width="600"><br>

<form name="special1" action="updateSpecials.cfm"
method="post">
<table width="600" cellpadding="3" cellspacing="0"
border="1">


<input type="hidden" name="id" value="1">
<tr>
<td class="text">Visible on Page:</td>
<td class="text"><input type="checkbox" name="special_visible"
</td>

</tr>
<tr>
<td class="text" valign="top" width="150"
align="right">Title:</td>
<td><input type="text" name="special_title"
value="IBM Refurbished Desktops" class="input"></td>
</tr>
<tr>
<td class="text" valign="top" width="150"
align="right">Price:</td>
<td><input type="text" name="special_price"
value="550.50" class=".dollarinput"></td>
</tr>
<tr>
<td class="text" valign="top" width="150"
align="right">Extra Price Info:</td>
<td><input type="text" name="extra_label"
value="$429.00 without monitor" class="input"></td>
</tr>
<tr>
<td class="text" valign="top" width="150"
align="right">Includes:</td>
<td><input type="text" name="includes" value="Add
Corel WP Office Suite & MacAfee Antivirus for $29.00"
class="input"></td>
</tr>

<tr>
<td class="text" valign="top" align="right">Special
Offer Details List:</td>
<td><textarea name="special_details" cols="20"
rows="10" wrap="virtual" class="comments2"><li>IBM P4, 2.0GHz
<li>256MB RAM
<li>40GB/FDD
<li>New CDRW
<li>Keyboard
<li>Mouse & Speakers
<li>10/100 NIC
<li>New 17" Monitor
<li>Windows 2000 Professional
<li>Test item</textarea></td>
</tr>
<tr>
<td class="text" valign="top" width="150"
align="right">Image Name </td>
<td><input type="text" name="special_image"
value="empty.jpg">&nbsp;<A HREF = "javascript:newupload('special1',
'special_image')">Upload New Image</A></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit"
name="btn" value="Update"></td>
</tr>

</table>
</form>
<p></p>

<form name="special2" action="updateSpecials.cfm"
method="post">
<table width="600" cellpadding="3" cellspacing="0"
border="1">


<input type="hidden" name="id" value="2">
<tr>
<td class="text">Visible on Page:</td>
<td class="text"><input type="checkbox" name="special_visible"
checked></td>
</tr>
<tr>
<td class="text" valign="top" width="150"
align="right">Title:</td>
<td><input type="text" name="special_title"
value="Lexmark Z615" class="input"></td>
</tr>
<tr>
<td class="text" valign="top" width="150"
align="right">Price:</td>
<td><input type="text" name="special_price"
value="49.00" class=".dollarinput"></td>
</tr>
<tr>
<td class="text" valign="top" width="150"
align="right">Extra Price Info:</td>
<td><input type="text" name="extra_label" value=""
class="input"></td>
</tr>
<tr>
<td class="text" valign="top" width="150"
align="right">Includes:</td>
<td><input type="text" name="includes" value="Factory
Refurbished Printer" class="input"></td>
</tr>

<tr>
<td class="text" valign="top" align="right">Special
Offer Details List:</td>
<td><textarea name="special_details" cols="20"
rows="10" wrap="virtual" class="comments2"><li>Black & colour
cartridges
<li>1 year manufacturers warranty
</textarea></td>
</tr>
<tr>
<td class="text" valign="top" width="150"
align="right">Image Name </td>
<td><input type="text" name="special_image"
value="z615.jpg">&nbsp;<A HREF = "javascript:newupload('special2',
'special_image')">Upload New Image</A></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit"
name="btn" value="Update"></td>
</tr>

</table>
</form>
<p></p>

</table><br><br></td>
</tr>
</table>
</body>
</html>

Feb 2 '06 #4

P: n/a
Hi Mick,

Thx for the reply, 1 more thing

what I need to do is really get this line..

opener.document.Special1.special_image.value=iName ;

when I hardcode that it returns the proper value to the opener, how
would i use your function to get the value in there..

I tried this.. but got an error

<SCRIPT LANGUAGE="JavaScript">
<!--

function getFormNamesFromOpener(){
var f=window.opener.document.forms,ff=f.length,ARR=[];
while(ff--) {ARR.push(f[ff].name}
return ARR;

}

function setimagename(iName)
{

opener.document.getFormNamesFromOpener().special_i mage.value=iName;

/*close();*/

}
//-->
</SCRIPT>

Feb 2 '06 #5

P: n/a
dr****@canoemail.com wrote:
Hi Mick,

Thx for the reply, 1 more thing

what I need to do is really get this line..

opener.document.Special1.special_image.value=iName ;

when I hardcode that it returns the proper value to the opener, how
would i use your function to get the value in there..

I tried this.. but got an error

<SCRIPT LANGUAGE="JavaScript">
<!--

function getFormNamesFromOpener(){
var f=window.opener.document.forms,ff=f.length,ARR=[];
while(ff--) {ARR.push(f[ff].name}
return ARR;

}

function setimagename(iName)
{

opener.document.getFormNamesFromOpener().special_i mage.value=iName;

opener.document.forms[getFormNamesFromOpener()[0]].special_image.value=iName;

or simply:

opener.document.forms[0].special_image.value=iName;

Mick

/*close();*/

}
//-->
</SCRIPT>

Feb 2 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.