Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Problem creating a Javascript variable to a VALUE

Explorer ,
Aug 06, 2008 Aug 06, 2008
I run a java script to tell me what the screen width is. It returns 1680, but when I try to run a cfif statement, involving math, it says its not a value.

So I attempted to convert the info to a value..... it then changes 1680 to 0.

I'm totally lost. Below is the code where I;m trying to convert what appears to be a number to..... well a NUMBER!! Feel free to cut and paste and try yourself. I t will convert whatever your screen width is to a 0 (ZERO)!!

Please help me out. I want to eventually say: If scrren size LT 800 go here. But I cannot do that because it doesn't see my screensize as a value.

Thanks in advance for any and all help!!!!
420
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 06, 2008 Aug 06, 2008
javascript runs on the client. cold fusion runs on the server.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 06, 2008 Aug 06, 2008
I understand one is server side and one is client. But I was already able to convert the Java variable to a session variable.... I just need a way to make it seen as a NUMBER
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 06, 2008 Aug 06, 2008
Firebug_web wrote:
>... I was already able to convert the Java variable to a session variable....

No. You have set the session variable equal to a string of text. Your browser may be able to evaluate the string and return a number like 800. But to ColdFusion it still a string of text, not a number. Cfdump the variable and look at the results.

<cfdump var="#session.pageTitle#">
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 06, 2008 Aug 06, 2008
ah.... I see. When I do the dump it just shows the string of text.

So is there a way anyone here can think of to get a java variable and turn it into a CF one?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 06, 2008 Aug 06, 2008
LATEST
Firebug_web wrote:
> So is there a way anyone here can think of to get a java
> variable and turn it into a CF one?

To pass information from the client browser back to the server, you must submit another request. There are different ways to do that: submitting a form, using ajax, etcetera. How you submit the request is up to you.

You may want to read this thread. It contains a good description of the communication process between client browser and ColdFusion, which explains why another request is necessary.
http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:57175#310077

> java variable

Java script variable. There is a significant difference between the two ;-)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources