Copy link to clipboard
Copied
I am submitting from a.cfm to b.cfm. b.cfm opens in a Javascript window. In b.cfm, the form elements from a.cfm are lost and cgi.referer returns nothing.
When I don't open b.cfm in a Javascript window, everything is ok.
What is this happening?
Perhaps, even neater:
function f(nextpg_,nextwin_)
{
var _attrs='';
var _br=navigator.appName;
document.forms[0].method="post";
document.forms[0].action=nextpg_;
document.forms[0].target=nextwin_;
etc., etc
}
Copy link to clipboard
Copied
Hi,
Can you please post your complete code here?.
Copy link to clipboard
Copied
NOw it is aa.cfm and bb.cfm. aa.cfm is the first one, bb.cfm the second one.
<html>
<head>
<script language="javascript">
function fie_(nextpg_,nextwin_)
{
var _attrs='';
var _br=navigator.appName;
if (_br=='Microsoft Internet Explorer')
{
_attrs='height='+screen.height+',width='+screen.width+'toolbar=0,menubar=0';
_attrs=_attrs+'top=0,left=0';
window.opener=null;
window.close();
window.open(nextpg_,nextwin_,_attrs)
}
else
{
alert('Internet Explorer Please.')
}
}
</script>
</head>
<body>
<form>
<input name="aabb" type="text" value="0">
<input type="submit" value="*" onClick="fie_('bb.cfm','x')"> <!--- onClick="fie_('bb.cfm','x')" --->
</form>
</body>
</html>
<html>
<head>
<title>
</title>
<!--- <meta http-equiv="refresh" content="5"> --->
</head>
<body>
<cfoutput>
___*#aabb#*___*#cgi.referer#*___*#cgi.script_name#*___*#now()#*
</cfoutput>
<form>
<input type="submit" value="**">
</form>
</body>
</html>
Copy link to clipboard
Copied
It's because you are using javascript. If you really need a new window, target = "blank" is a lot simpler.
Copy link to clipboard
Copied
I am submitting from a.cfm to b.cfm. b.cfm opens in a Javascript window. In b.cfm, the form elements from a.cfm are lost and cgi.referer returns nothing. When I don't open b.cfm in a Javascript window, everything is ok.
What is this happening?
The reason is simple really. Your code does not submit the form! Replace your Javascript with the following, and you will see it for yourself
<script language="javascript">
function fie_(nextpg_,nextwin_)
{
var _attrs='';
var _br=navigator.appName;
if (_br=='Microsoft Internet Explorer')
{
_attrs='height='+screen.height+',width='+screen.width+'toolbar=0,menubar=0';
_attrs=_attrs+'top=0,left=0';
window.opener=null;
// window.close();
// window.open(nextpg_,nextwin_,_attrs)
}
else
{
alert('Internet Explorer Please.')
}
// submit form to the page nextpg_
document.forms[0].action=nextpg_;
}
</script>
Copy link to clipboard
Copied
Should have seen that. Tried putting action in but no luck.Also tried putting in method="post" in form tag. Still cannot get value to next page. Any suggestions would be appreciated.
Copy link to clipboard
Copied
When I use your code, plus the modified script I showed in my last post, the values appear on the action page. Start from there.
Copy link to clipboard
Copied
The problem is when the line that says window.open(nextpg_,nextwin_,_attrs) is uncommented.
It works when bbb.cfm opens in a regular browser window but "variable aabb not defined" when try to open in window.
I hope to find out what I'm doing wrong and also try sending aabb with method get.
Edit--Got it to work with method get. Still want to send over form element without passing as params.
Message was edited by: lwfg
Copy link to clipboard
Copied
You should set up the form attributes before the window opens. Like this, for example
<script language="javascript">
function fie_(nextpg_,nextwin_)
{
var _attrs='';
var _br=navigator.appName;
document.forms[0].method="post";
document.forms[0].action=nextpg_;
if (_br=='Microsoft Internet Explorer')
{
_attrs='height='+screen.height+',width='+screen.width+'toolbar=0,menubar=0';
_attrs=_attrs+'top=0,left=0';
window.opener=null;
// window.close();
window.open(nextpg_,nextwin_,_attrs)
}
else
{
alert('Internet Explorer Please.')
}
}
</script>
Copy link to clipboard
Copied
Thanks, that makes sense. I'm surprised the same thing's happenning though.
-- If aaaa.cfm submits to bbbb.cfm without openning a Javascript window, the value of a passes along fine.
-- Passing a as a parameter in the url works too.
-- It's when I try to open bbbb.cfm in a Javascript window that I get the error "variable a undefined".
-- Someone had a similar problem, http://www.tek-tips.com/viewthread.cfm?qid=1441288&page=19 .Adapted it but had to pass parameter in url.
What can I do to make his work with a submit or button type?
This is aaaa.cfm
<html>
<head>
<script language="javascript">
function fie_(nextpg_,nextwin_)
{
var _attrs='';
var _br=navigator.appName;
document.forms[0].method="post";
document.forms[0].action=nextpg_;
if (_br=='Microsoft Internet Explorer')
{
_attrs='height='+screen.height+',width='+screen.width+'toolbar=0,menubar=0';
_attrs=_attrs+'top=0,left=0';
window.opener=null;
//window.close();
window.open(nextpg_,nextwin_,_attrs)
}
else
{
alert('Internet Explorer Please.')
}
}
</script>
<title>
</title>
</head>
<body>
<form name="f">
<cfset a=0>
<cfoutput>
<input name="a" type="text" value="#a#">
</cfoutput>
<input name="sf" type="submit" value="*" onClick="fie_('bbbb.cfm,''x')">
</form>
</body>
</html>
This is bbbb.cfm
<html>
<head>
<title>
</title>
</head>
<body>
<cfoutput>
*#a#*#now()#*
</cfoutput>
</body>
</html>
Copy link to clipboard
Copied
There's nothing the matter. You simply made a typing mistake.
fie_('bbbb.cfm,''x')
Should be: fie_('bbbb.cfm','x')
Copy link to clipboard
Copied
Still getting the same thing.
When sf is clicked in aaaa.cfm, bbbb.cfm does not see the variable named "a".
When the link with the * is clicked, bbbb.cfm sees "a".
What on earth am I doing wrong?
This is aaaa.cfm.
<html>
<head>
<script language="javascript">
function f(nextpg_,nextwin_)
{
var _attrs='';
var _br=navigator.appName;
document.forms[0].method="post";
document.forms[0].action=nextpg_;
if (_br=='Microsoft Internet Explorer')
{
_attrs='height='+screen.height+',width='+screen.width+'toolbar=0,menubar=0';
_attrs=_attrs+'top=0,left=0';
window.opener=null;
window.close();
window.open(nextpg_,nextwin_,_attrs)
}
else
{
alert('Internet Explorer Please.')
}
}
function g(nextpg_,nextwin_,val)
{
var _attrs='';
var _br=navigator.appName;
document.forms[0].method="post";
document.forms[0].action=nextpg_;
if (_br=='Microsoft Internet Explorer')
{
_attrs='height='+screen.height+',width='+screen.width+'toolbar=0,menubar=0';
_attrs=_attrs+'top=0,left=0';
window.opener=null;
window.close();
window.open(nextpg_+'?a='+val,nextwin_,_attrs)
}
else
{
alert('Internet Explorer Please.')
}
}
</script>
<title>
</title>
</head>
<body>
<form name="ff">
<cfset a=0>
<cfoutput>
<input name="a" type="text" value="#a#">
</cfoutput>
<input name="sf" type="submit" value="*" onClick="f('bbbb.cfm','windowname')">
<a href="javascript:g('bbbb.cfm','x','<cfoutput>#a#</cfoutput>')">
*
</a>
</form>
</body>
</html>
This is bbbb.cfm
<html>
<head>
<title>
</title>
</head>
<body>
<cfoutput>
*#a#*#now()#*
</cfoutput>
</body>
</html>
Copy link to clipboard
Copied
Could you please have the courtesy to acknowledge questions that have been answered, before proceeding to ask further questions? I have answered at least 2 questions. What you've simply been doing is add more script, yet saying you don't know what you are doing wrong!
Copy link to clipboard
Copied
What on earth am I doing wrong?
This time?
<a href="javascript:g('bbbb.cfm','x','<cfoutput>#a#</cfoutput>')">
*
</a>
I would put the cfoutput tag outside, like this:
<cfoutput><a href="javascript:g('bbbb.cfm','x','#a#')">open page bbbb</a></cfoutput>
Copy link to clipboard
Copied
BKBK, Sorry that I seemed discourteous. I never meant to be.
The "more script" was just my latest tries.
g() works tags inside or out but thank you for the suggestion about putting the tags outside.
Still don't understand why f() won't work when opening a new window but does work when not opening a new window.
Again,I guess I should've acknowleged each of your replies as they came. I really do appreciate your time and effort.
Copy link to clipboard
Copied
why f() won't work when opening a new window but does work when not opening a new window.
To correct that, specify the new window as target for the form.
<body>
<form name="ff" target="windowname">
<cfset a=0>
<cfoutput>
<input name="a" type="text" value="#a#">
</cfoutput>
<input name="sf" type="submit" value="*" onClick="f('bbbb.cfm','windowname')">
</form>
<cfoutput><a href="javascript:g('bbbb.cfm','x','#a#')">open page bbbb</a></cfoutput>
</body>
Copy link to clipboard
Copied
Perhaps, even neater:
function f(nextpg_,nextwin_)
{
var _attrs='';
var _br=navigator.appName;
document.forms[0].method="post";
document.forms[0].action=nextpg_;
document.forms[0].target=nextwin_;
etc., etc
}
Copy link to clipboard
Copied
document.forms[0].target=nextwin_; fixed it. I'm pretty happy about this. Thanks.
Copy link to clipboard
Copied
document.forms[0].target=nextwin_; fixed it. I'm pretty happy about this. Thanks.
It's all right.