Link to home
Start Free TrialLog in
Avatar of RussoMA
RussoMA

asked on

Passing Javascript to ColdFusion variables?

I have a parent window, spawning a child window with an onChange open() command to open a separate window when a textbox in a cfinput statement changes...

Parent Window:
<cfinput name="myinput" type="text" onchange="open('insurance.cfm', 'prevWin', 'status,width=640,height=500,scrollbars=yes');">

In the spawned child window ('prevWin') I am performing this onload:

<script language="JavaScript">
<!--
function getsearch() {
myvalue=window.opener.pathdemo.myinput.value;
}
//-->
</script>
<body onLoad="getsearch();">

i am wondering how i can call that "myvalue" into play in a cfquery such that i could do a

SELECT * From searchtable
WHERE searchterm like '%myvalue%'

I have attempted to call: <cfset myvariable = myvalue>  

i only need to know how to reference back to the javascript variable as i am used to only working wtih CF variables, not JS...

time is of the essence on getting this small answer.
ASKER CERTIFIED SOLUTION
Avatar of Pravin Asar
Pravin Asar
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RussoMA
RussoMA

ASKER

thanks all... good information for answering this question as well as steering the learning onto other new technologies (i've only recently heard of AJAX in software development magazine, when they talked about some webdev software called Ruby on Rails)... definitely gonna look more into it though.  

Thanks again
-ed
Hi, I'm facing the same problem now, did you ever find a solution using AJAX & CF?
The solution is really within the options that were presented. If you pass variables through the url, then you can access them in coldfusion from the url scope, if you assign values to an html input, be it hidden or otherwise, then you can access those values via the form scope. Both require a page submission because you have to go back to the server so coldfusion can read the values. No matter which way you look at it you always have to make a call to the server where the coldfusion code resides. Now you can make that call in the background through javascript, and with the gaining popularity in AJAX you now have a couple AJAX options for background processing as well. You can also take advantage of some popular javascript libraries that ease the pain of setting up AJAX requests and provide support for JSON as well.

If you're interested in AJAX & CF, or JSON & CF, check out the JQuery javascript library; this is a rather less complicated library to use if you're starting out, everything is pretty straight forward, and I believe they have some documentation available specifically for interacting with CF. Just search for JQuery in your favorite search engine and you'll find it pretty quick. If you want to check out the many other libraries available search for "popular javascript libraries". There are several blogs and articles that list many of the popular libraries available.

-tb55