Click to See Complete Forum and Search --> : Simple Debug


draknoir42
11-14-2003, 10:22 AM
im new to JavaScript and cant get this particular line to work:

<a href="home.cfm" onClick="document.home.src='darktab.jpg'; document."+currentTab+".src='lighttab.jpg'; currentTab='home';">Home</a>

currentTab is a string, alway equal to the name of one of several images in the document

pixelmech
11-14-2003, 10:49 AM
Drak, what are you trying to do? Make a rollover? Am I correct in assuming "home" is a link?

In any event, you are setting an image on the onclick event which I don't quite understand. When you click that link you are going to go to home.cfm.

Can you try and rewrite you question more completely and add some more code (the html part would help)

Tom

neil9999
11-14-2003, 11:00 AM
if you want an image to link to another page, use either:

<a href="index.htm"><image src="mypic.jpg"></a>

or

<image src="mypic.jpg" onclick="window.location='index.htm'">

The last will only work with javascript enabled browsers.

If you want to go to another page when you put your mouse over the pic, use:

<image src="mypic.jpg" onmouseover="window.location='index.htm'">

This will also only work with javascript enabled browsers.

Neil

draknoir42
11-17-2003, 08:17 AM
This code is in the top frame of a page. the default target of the frame is the lower frame. onClick I want the home.cfm to open in the bottom frame, I also want the image named home to to swap to darktab.jpg. Finally, i want the image with the same name as the string value of currentTab to be swaped with lighttab.jpg

pixelmech
11-17-2003, 09:14 AM
Originally posted by draknoir42
This code is in the top frame of a page. the default target of the frame is the lower frame. onClick I want the home.cfm to open in the bottom frame, I also want the image named home to to swap to darktab.jpg. Finally, i want the image with the same name as the string value of currentTab to be swaped with lighttab.jpg

You don't need JS (nor should you use it) to load an HTML page into a frame. Simpy use HTML:


<a href="home.cfm" target="yourBottomFrameName">link</a>


As for the images, since you are using CF I would do it server side. JS would work, but its not ideal for this type of thing. You aren't really wanting a rollover but you are wanting to tell the user what page they are on.

I don't do CF but here is an PHP example:


"$tabname" ($ is a variable in PHP) is set in the header:

<? if($tabname == "home"){ ?>
<img src="_images/home_on.gif" width="100" height="36" alt="" border="0" name="home" />
<? }else{ ?>
<img src="_images/home_off.gif" width="100" height="36" alt="" border="0" name="home" />
<?}?>


So based on what page I am on, the "on" or "off" version is loaded. You could pass the variable in the querystring:

<a href="home.cfm?page=home"...

and pull it off that way.

HTH

Tom