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 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macintosh point me in the right direction

    as part of the homework, we are to place 3 buttons on the page, and when you click on them, they dont take you anyplace until you click on a url link, which will take you to one of 3 places, depending on which button you click first. is this a particular type of function? do you store the 'link' to access later? and how? i would search, but dont know what to call this kind of action.

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    are the links supposed to be visible before you click the buttons?

    if so, is this what you mean?

    Code:
    <script>
    function changeLinks(url1,url2,url3){
        document.getElementById('link1').href=url1;
        document.getElementById('link2').href=url2;
        document.getElementById('link3').href=url3;
    }
    </script>
    <a id="link1" href="#">Link 1</a>
    <br />
    <a id="link2" href="#">Link 2</a>
    <br />
    <a id="link3" href="#">Link 3</a>
    <br />
    <input type="button" value="Button 1" onClick="changeLinks('url1','url2','url3');">
    <br />
    <input type="button" value="Button 2" onClick="changeLinks('url1','url2','url3');">
    <br />
    <input type="button" value="Button 3" onClick="changeLinks('url1','url2','url3');">
    <br />
    replace the bolded green texts with links for link 1, 2, and 3 for their respective buttons.
    Last edited by boeing747fp; 08-02-2006 at 04:09 AM.

  • #3
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    my buttons are going to be called heaven, purgatory, and hell. when you click on heaven, it will 'store' the reference to apple.com, purgatory will hold linux and hell will hold ms.... but you wont go to the respective sites till you click an href link that states, click here to go to your chosen destination.... does that change anything of what you posted?

  • #4
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    Code:
    <script>
    function changeLink(text,link){
        document.getElementById('link').innerHTML=text;
        document.getElementById('link').href=link;
    }
    </script>
    <body>
    <a id="link" href=""></a>
    <br />
    <input type="button" value="Heaven" onClick="changeLink('Click Here to go to Apple','http://apple.com/');">
    <input type="button" value="Purgatory" onClick="changeLink('Click Here to go to Linux','http://linux.org/');">
    <input type="button" value="Hell" onClick="changeLink('Click Here to Go to Microsoft','http://microsoft.com/');">
    </body>
    Last edited by boeing747fp; 08-02-2006 at 06:25 AM.

  • #5
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    LadyiMac bows to the buddah nature of boeing747fp. That is absolutely perfect.

  • #6
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    LadyiMac, what's the point in taking that class you're taking if you have someone do your homework for you?

    boeing747fp, why are the first "c"s in "onclick" capitalized when the use of "<br />" instead of "<br>" indicates you are using XHTML?
    Last edited by Kravvitz; 08-02-2006 at 09:01 AM.
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

  • #7
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    i always put onClick.... is there really a difference between onclick and onClick ??
    Last edited by boeing747fp; 08-02-2006 at 10:59 AM.

  • #8
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes. XHTML is case-sensitive. In XHTML, there is no such thin as "onClick", but "onclick" does exist.

    It's bad practice to use inline event handlers.

    I suggest you both read these:
    Behavioral Separation
    Unobtrusive JavaScript
    DOM Scripting - Sample chapter: Best Practices
    Accessible DHTML
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

  • #9
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    well... i dont really know the difference between html and xhtml or whatever.... dreamweaver does <br /> so who knows... and i just wrote a quick code based on what she wanted done (with Buttons)... and just wondering.... why does XHTML not allow onClick yet it works in the browsers?
    Last edited by boeing747fp; 08-03-2006 at 01:04 AM.

  • #10
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Until you learn the many differences stick with HTML and "<br>".

    One of XHTML's rules is that all element and attribute names must be in lower-case.

    Unless you're using DreamWeaver 8, you should find a new text editor.
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

  • #11
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    yea im using dw 8... thanks for those documentations... i'll study up on that stuff.


  •  

    Posting Permissions

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