...

View Full Version : onClick question



emyrlin
12-18-2002, 01:14 PM
I'm currently creating a site as a major assignment in school, so this is pretty important to me.

The site is <a href="http://freewebs.com/emyrlin">here</a> for you to view and keep up with what I'm talking about.

I was told that I should use a different colored button in the left frame when someone visits the links under each topic button. (i.e. if someone clicks How To and explores the links connected to that button, the HowTo button should have another color.)

The problem is that I already use onMouseover for those buttons, and onClick to open the link in two separate frames (area and bottom). Now, is it possible to put in yet another onClick function that changes the button to a different one?

Help muchly appreciated!
Emma

requestcode
12-18-2002, 01:37 PM
You can perform muliple function with the onClick by separating them with a semicolon. Here is an example:
<html>
<head>
<title>Change Button Color</title>
<SCRIPT LANGUAGE="JavaScript">
count=0
function chgbgcolor(obj)
{
if(count==0)
{
count++
obj.style.background="red"
}
else
{
count=0
obj.style.background="yellow"
}
}
function doalert()
{
alert("Color Changed!")
}
</SCRIPT>
</head>
<body>
<FORM NAME="myform">
<INPUT TYPE="button" VALUE="Click" onClick="chgbgcolor(this);doalert()" STYLE="background:yellow">
</FORM>
</body>
</html>

Catman
12-18-2002, 01:39 PM
Just add another function to your existing onclick, e.g.:



onclick="function1(smith); function2(jones); function3(alias);"


Of course, you'll need to devise a function to make the color change.

emyrlin
12-18-2002, 04:17 PM
It's not a radio button, it's actually an image, a jpg of a button to click. :)

It didn't work with the adding of an extra function; but here's the code so you'll know how it looks:

<a href="howto.html" target="area" onClick="javascript:
var url='howtolinks.html';
window.top.frames['bottom'].location.href=url;
return true; " onMouseOver="javascript:
document.images['howto'].src=image02.src;
return true;" onMouseOut="javascript:
document.images['howto'].src=image01.src;
return true;"><img vspace="0" src="images/howto1a.jpg"
name="howto" border="0"></a>

requestcode
12-18-2002, 08:21 PM
I don't believe you will be able to change the image with the onClick because you are also changing it with the onMouseOut. The onClick would change the image to a different one, but then once you mouse out the image would be changed again.

joeframbach
12-18-2002, 08:48 PM
keep all the events in functions in the <head> and just pass the files needed for each event. also keep a global boolean variable that, if false (or true) will nullify the onMouseOut for that link.
this may seem confusing, but take it a step at a time and NEVER overcomplicate it!

whammy
12-19-2002, 01:41 AM
If you're using frames, this shouldn't be a problem... just change the "navigation" frame to have your "clicked" navigation link (picture) show a different image. I'm assuming that your "main frame" changes when this link is clicked. i.e.:

<img onclick="this.src='whatever.jpg'" />

This gets a slight bit more complicated if you're using include files, etc. instead of frames, but this should be pretty easy in this instance...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum