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

Passing a form variable into a popup window 2

Status
Not open for further replies.

aleci

Programmer
May 22, 2001
40
GB
Hi,
Is it possible to pass a variable from a CF template (via a hidden form field) into a JavaScript popup window ?

The name of the page with the form (and so the variable) in is story.cfm
The name of the page i wish to load into the popup is mail_set.cfm
I wish to refer to this variable in mail_set.cfm (in the popup window!)

I have tried the following:

<SCRIPT language=JavaScript>
function topWindow1(){
popup = window.open(&quot;mail_set.cfm&quot;,&quot;&quot;,&quot;height=300,width=580,scrollbars=no&quot;);
}
</SCRIPT>

<FORM onsubmit=javascript:topWindow1(); method=&quot;post&quot;>
<input type=&quot;Hidden&quot; name=&quot;article_number&quot; value=&quot;#variable#&quot;>
<INPUT type=submit value=&quot;Submit Query&quot;>
</FORM>

This caused a error in the popup window saying that the variable wasnt defined.
Does anyone please see anything wrong with this code, or is what im trying to do even possible?

Thanks in advance
 
Here, this works:

<cfset var = 2>

<FORM action=&quot;&quot; method=&quot;post&quot;>
<cfoutput>
<INPUT type=submit value=&quot;Submit Query&quot; onClick=&quot;javascript:window.open('mail_set.cfm?article_number=#var#','','height=300,width=580,scrollbars=no');&quot;>
</cfoutput>
</FORM>


Then, on mail_set.cfm, reference the variable with:

<cfoutput>
#URL.article_number#
</cfoutput>

Will that work for you?

John Hoarty
jhoarty@quickestore.com
 
Hi John,
Thank you very much for your time.
For a moment i thought this did actually work because when the popup window appeared there was no CF error claiming the variable was undefined, as happened before.

However when i tried to reference the actual variable i realised that i couldnt!

Strange, i thought, since it seems to have been passed OK because of the lack of an error!

I copied your code exactly into a couple of new pages to test it and the same occurred - i couldnt actually output the variable.
Do you have any more ideas?
Thanks in advance
 
Scratch that, it works perfectly!
Made a mistake in copying it over!
thanks for the help john
 
If I may intrude, how would you do the same with a hidden variable?? ----------------------------------------
If you are reading this, then you have read too far... :p

lightwarrior@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top