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

pass CF variable to Javascript Pop-up window

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi every one,

Does any one know how to pass a Coldfusion varible to a Javascript Pop-up window? I know we can open a new window by using window.open in javascript, but how to fill it with some CF varibles. Help!

Shukui
 
Embed the javascript code in cfoutput and use #coldfusionvariable#.

<cfoutput>

<script language=&quot;javascript&quot;>
window.open(&quot;something.com&quot; #yourvariable#)

</script>
</cfoutput>
 
hi Shukui

There are a lot of ways to do this, but this is probably the easiest. It assumes that the template you're opening in the new window is a CFM template, and that its will act on variables passed via the URL.
<!--- link to javascript function --->
<CFOUTPUT>
<a href=&quot;javascript: newwin('mytitle','mytemplate.cfm?var=#myvar#')&quot;>New Window</a><br>
</CFOUTPUT>


<!--- function to open window --->
<script language=&quot;javascript&quot;>
<!--
winsetting = 'width=650,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no';

function newwin(title,url)
{
xxxwin=window.open (link, title, winsetting);
xxxwin.focus();
}

//-->
</script>

A more complicated method will allow the passed variable to be assigned to a hidden field in a form on the new window's template... but if the URL method works for you use that one.

let me know if i helped and joine this forum!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top