get dynamic formname and return value to opener

D

drdave

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','width=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=iName;*/

/*close();*/

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

lallous

Hello Dave,

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

mick white

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','width=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
 
D

drdave

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,height=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>
</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>
 
D

drdave

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_image.value=iName;

/*close();*/

}
//-->
</SCRIPT>
 
M

mick white

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_image.value=iName;


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

or simply:

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

Mick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top