Skip to main content
Inspiring
August 6, 2008
Question

Problem creating a Javascript variable to a VALUE

  • August 6, 2008
  • 3 replies
  • 461 views
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!!!!
    This topic has been closed for replies.

    3 replies

    Inspiring
    August 6, 2008
    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 ;-)
    Inspiring
    August 6, 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?
    Inspiring
    August 6, 2008
    javascript runs on the client. cold fusion runs on the server.
    Inspiring
    August 6, 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
    Inspiring
    August 6, 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#">