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

Javascript and Coldfusion

Status
Not open for further replies.

SkylordRU1

Technical User
Aug 31, 2000
4
US
I have this Java Script Below. take a look it's a simple roll over trying to call the new image from the database.

<SCRIPT LANGUAGE=&quot;JScript&quot;>
Aregular = new Image; Aregular.src = &quot;#rootMapping#navbarImages1/#pagelink#&quot;;
Ayellow = new Image; Ayellow.src = &quot;#rootMapping#navbarImages/#pagelink#&quot;;
function MouseOverRoutine(ButtonName)
{
if (ButtonName==&quot;button1&quot;)
{document.button1.src = Aregular.src;}
}
function MouseOutRoutine(ButtonName)
{
if (ButtonName==&quot;button1&quot;)
{document.button1.src = Ayellow.src;}
}
</script>

The Links in my Navigation bar are images I call on the fly from the database with certain page #'s assigned to them by the #pagelink# assignment. I want to use the script above to comunicate the expression below.

<tr><td><a href=&quot;#pageURL#&quot; onmouseOver=&quot;MouseOverRoutine('button1')&quot; onmouseOut=&quot;MouseOutRoutine('button1')&quot;><img src=&quot;#rootMapping#navbarImages/#pagelink#&quot; Border=&quot;0&quot; width=&quot;180&quot; height=&quot;21&quot;></a><br></td></tr>

Everything works but the Java Script it keeps telling me that the document.button1 is not an object.

Can anyone help?
 
Hi!

it would really work better if you would have inclued in your <img src> the name of your image:

<img src=&quot;#rootMapping#navbarImages/#pagelink#&quot; Border=&quot;0&quot; width=&quot;180&quot; height=&quot;21&quot;>

<img src=&quot;#rootMapping#navbarImages/#pagelink#&quot; Border=&quot;0&quot; width=&quot;180&quot; height=&quot;21&quot; name=&quot;button1&quot;>

try it not sure it will solve completly your problem but it will help for sure...

Chris!
 
Hey Chris,

The #pagelink# is suppost to be calling the image from the database depending on the page number assigned to it!



 
SkylordRU1,
Since you script refer an object named button1 you must have it inside your html page.

I believe you refer button1 for the image, therefore your code:

<img src=&quot;#rootMapping#navbarImages/#pagelink#&quot; Border=&quot;0&quot; width=&quot;180&quot; height=&quot;21&quot;>

should be changed to:

<img src=&quot;#rootMapping#navbarImages/#pagelink#&quot; Border=&quot;0&quot; width=&quot;180&quot; height=&quot;21&quot; id=&quot;button1&quot; name=&quot;button1&quot;>

Please give a try and let me know the outcome.

Djon [sig][/sig]
 
Hey it doesn't give me an error anymore, but it doesn't rollover either.

The address is
I'm trying to just do this one section for now. The code is-

<!--- RollOver --->
<SCRIPT LANGUAGE=&quot;JScript&quot;>
<!--
Aregular = new Image; Aregular.src = &quot;<img src=#rootMapping#navbarImages1/#pagelink#>&quot;;
Ayellow = new Image; Ayellow.src = &quot;<img src=#rootMapping#navbarImages/#pagelink#>&quot;;
function MouseOverRoutine(ButtonName)
{
if (ButtonName==&quot;button1&quot;)
{document.button1.src = Aregular.src;}
}
function MouseOutRoutine(ButtonName)
{
if (ButtonName==&quot;button1&quot;)
{document.button1.src = Ayellow.src;}
}
//-->
</script>

<tr><td><a href=&quot;#pageURL#&quot; onmouseOver=&quot;MouseOverRoutine('button1')&quot; onmouseOut=&quot;MouseOutRoutine('button1')&quot;><img src=&quot;#rootMapping#navbarImages/#pagelink#&quot; Border=&quot;0&quot; width=&quot;180&quot; height=&quot;21&quot; id=&quot;button1&quot; name=&quot;button1&quot;></a><br></td></tr>

Without the ID=&quot;button1&quot; and Name=&quot;button1&quot; is gives me an error with them in it doesn't, but it still doesn't do the rollover!

Thanks Bruce
 
I had viewed your site (with Netscape 4.75), and the navbar button did change color when I moved my mouse over it.

I have tried with IE 5 and it's true that the navbar didn't change color.

Well, the browser war (IE & NN behave differently) has caused us web programmer to spend hours to make a cross browser web.

Since I see there is nothing wrong with the code maybe you can try to change
<SCRIPT LANGUAGE=&quot;JScript&quot;> with <SCRIPT LANGUAGE=&quot;javascript&quot;>

Djon [sig][/sig]
 

Try this:

<!--- RollOver --->
<SCRIPT LANGUAGE=&quot;JScript&quot;>
<cfoutput>
<!--
Aregular = new Image;
Aregular.src = &quot;#rootMapping#navbarImages1/#pagelink#&quot;;
Ayellow = new Image;
Ayellow.src = &quot;#rootMapping#navbarImages/#pagelink#&quot;;
function MouseOverRoutine(ButtonName)
{
if (ButtonName==&quot;button1&quot;)
{document.button1.src = Aregular.src;}
}
function MouseOutRoutine(ButtonName)
{
if (ButtonName==&quot;button1&quot;)
{document.button1.src = Ayellow.src;}
}
//-->
</cfoutput>
</script>
<cfoutput>
<tr><td><a href=&quot;#pageURL#&quot;
onmouseOver=&quot;MouseOverRoutine('button1')&quot;
onmouseOut=&quot;MouseOutRoutine('button1')&quot;><img
src=&quot;#rootMapping#navbarImages/#pagelink#&quot; Border=&quot;0&quot; width=&quot;180&quot;
height=&quot;21&quot; id=&quot;button1&quot; name=&quot;button1&quot;></a><br></td></tr>
</cfoutput>

it should works fine.

Djon [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top