Skip to main content
Participant
July 27, 2010
Answered

Problem setting variables after initial page load

  • July 27, 2010
  • 2 replies
  • 708 views

So, I'm pretty new to ColdFusion and hoping this is an easy fix.  I have a .cfm page that opens from several different points in a website.  Depen

ding on which point it opens from, the variables room and activebutton are assigned different values via an onclick event.  Based on these values, the room variable sets a background image for a div and the activebutton sets the textcolor for a different div via a stylesheet in the head of the document.  Now, this part works fine with the following code in the stylesheet in the documents head:

#fp_r1_c2 {
background-image:url('images/<cfoutput>#room#</cfoutput>');
width:599px;
height:577px;
float:left;
}

#<cfoutput>#activebutton#</cfoutput>
{
color:#FFF;
}

Heres where things get hairy.  After I have those initial variables set there are 6 divs (the ones that activebutton changes the color attribute of) that the user can click on.  When any div is clicked its color should set to #FFF and whatever div was previously selected should change back to the default color for the page.  In addition, the background-image attribute of the other div that was set by the room variable must change to a new image that corresponds to each button.

I've tried several methods, most of which I probably messed up anyhow.  But I'm completely stumped how to accomplish this.  Researching online has shown me that I can't include the new values in any kind of onclick command...so how exactly should I go about accomplishing what I need done?

Tthanks in advance for any assistance!

This topic has been closed for replies.
Correct answer Dan_Bracuk

To change the page after it loads, use javascript.

2 replies

ilssac
Inspiring
July 27, 2010

Yup, Dan beat me to the answer.

ColdFusion is done by the time the user is interacting with the page.  To do anything in the user interface, JavaScript is the common choice.

tclaremont
Inspiring
July 27, 2010

You need to understand the underlying premise that ColdFusion is a "server-side" language. Once the page is generated and sent to the client as HTML, everything is in the hands of the client until the next request back to the server. So, if you want to do much in between server calls, a client-side tool such as JavaScript is the answer.

Vip19871Author
Participant
July 27, 2010

Gotchya, thanks guys.  I'll use Javascript for the subsequent actions.

Dan_BracukCorrect answer
Inspiring
July 27, 2010

To change the page after it loads, use javascript.