Solved

saving Javascript variable to coldfusion

Posted on 2012-03-29
6
250 Views
Last Modified: 2013-11-20
Here is my code.
What I am wanting to do is save the javascript variable to a coldfusion variable.
say using <cfset javaid = ?>  Any help is appreciated.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Main</title>
<script type="text/javascript">

function getParent(){

alert(parent.location);

}

</script>
</head>

<body>
<script type="text/JavaScript">
<!--


document.write(parent.location)

//-->
</script>
<br />


IP Address: <cfoutput>#CGI.REMOTE_ADDR#</cfoutput><br />
Path:<cfoutput>#CGI.SERVER_NAME##CGI.SCRIPT_NAME#</cfoutput><br />
Query:<cfoutput>#CGI.QUERY_STRING#</cfoutput><br />


</body>
</html>
0
Comment
Question by:rbm1tch3ll
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 37783271
saving Javascript variable to coldfusion

I think you're confused about client vs server side code.  You can't execute CF code from javascript. Javascript runs on the client (browser) and CF runs on the server. Neither one knows anything about the other.  To communicate with the CF server from javascript you need to submit another http request, such as using ajax, submitting a <form>, etc...

What's your ultimate goal in english, not code?
0
 
LVL 4

Expert Comment

by:sandy12879
ID: 37796077
try using cfwddx.
0
 
LVL 43

Expert Comment

by:Rob
ID: 39658267
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39658268
> save the javascript variable to a coldfusion variable

The answer is ID: 37783271 -  you can't.

Client side code executes after server side code is finished. To run more server side code you must submit a new request.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question