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

cf variable in mouseover event

Status
Not open for further replies.

evergreean43

Technical User
May 25, 2006
165
0
0
US
I am trying to show a cf variable in a mouseover event just in IE but it keeps giving me javascript error message in IE about "missing ;". If I take away the cf variable pound signs then there is not error message and the javascript browser sniffing works. But I need the pounds to grab my cf variable in JavaScript.

Please advise how I get the mouseover and cold fusion variable to work in javascript?

Code:
<a href="site.cfm" title="default message for the JavaScript free" onmouseover="this.title = navigator.appname == 'Netscape' ? 'netscape words here' : 'IE here #myvarhere#'">Link</a>
 
Output of var is one word with no special characters.

It seesm I can pull up a CF var using the mouseover event?
 
Output of var is one word with no special characters.

It seems I cant pull up a CF var using the mouseover event?
 
Are you actually parsing the variable before the page is shown to the user? (IE, do you have <cfoutput> tags anywhere?)

You can echo the variable into the code before the page loads, but you cannot possibly pull the varaible from Coldfusion using Javascript in this way. Coldfusion runs on the server-side, so you cannot interact with it using a client-side scripting language unless you actually send a request back to the server. (IE, submit a form)

Hope this helps

Wullie

Fresh Look - Quality Coldfusion 7/Windows Hosting
YetiHost - Coming Soon

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
Yes I do have the cfoutput tags set up:

Code:
<cfoutput>
<a href="site.cfm" title="default message with #myvarhere# for the JavaScript free" onmouseover="this.title = navigator.appname == 'Netscape' ? 'netscape words here' : 'IE here #myvarhere#'">Link</a>
</cfoutput>

It seems for the title property I can call a CF variable but not for a mouseover event.
 
Coldfusion is server-side and Javascript is client-side. Coldfusion variables when displayed to screen are absolutely no different from if you hard coded the text. This means that your problem cannot possibly be anything at all to do with Coldfusion and this is without a doubt a problem in your JS code or with the variable you are returning from Coldfusion.

Look at the source of the page (in the browser) when you are seeing the error, this will show you exactly what the problem is.

Hope this helps

Wullie

Fresh Look - Quality Coldfusion 7/Windows Hosting
YetiHost - Coming Soon

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top