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

How can I assign a variable with a JavaScript Function value return???

Status
Not open for further replies.

colosoderada

Programmer
Sep 14, 2000
26
ES
My question is:

if I have a JavaScript function

<script language=&quot;JavaScript&quot;>
int function Cambio(formulario){
int x, y = 10;
window.location=&quot;bo.01.cfm&quot;;
x = x * y;
return x;
}
</script>

How Can I to assign the result of the function to a variable????

<CFSET Result = ??????>

I have tried

<CFSET Result = #Cambio()#> (wrong)
<CFSET Result = '#Cambio()#'> (wrong)

Any idea, Thanks in advance.
 
It's the near classic problem of client-side and server-side processing. Javascript is being processed on the client, while CF is run on the server. So at the moment the Javascript will get executed, the only way you can store the result of your function in a CF variable, is to send the page back to the server so CF can store it and send it back to the browser. Not a good option I think ;-).
Consider writing a CF function that can do the trick for you. Another possibility is WDDX which can exchange data between CF and Javascript (it's XML-based), but things will get quite complicated then I'm afraid.
My suggestion is to write a CF function. Let me know if you can figure it out! Good luck

<webguru>iqof188</webguru>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top