Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Dec 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onClick question

    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

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Ames, IA, USA
    Posts
    373
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just add another function to your existing onclick, e.g.:

    Code:
    onclick="function1(smith);  function2(jones); function3(alias);"
    Of course, you'll need to devise a function to make the color change.
    Need more emoticons?
    Visit Catman's Private Stock

  • #4
    New to the CF scene
    Join Date
    Dec 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    no working

    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>

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Regular Coder
    Join Date
    Dec 2002
    Location
    a bit west of pittsburgh
    Posts
    236
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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!

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...
    Last edited by whammy; 12-19-2002 at 01:45 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •