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

    Changing button content and link when clicked

    Hi all,

    I am running a website and I want to display many things on the same page. Currently what I have is something like this:

    Code:
    [two buttons here]
    
    [some code here, showing]
    
    [some code here, hiding]
    When i click the second button, the hidden code replaces the code that was just showing. The first button then re-hides that code and shows the first code again. What I want to do is combine the two buttons so that when you click the first one, the text and hyperlink will change to display that of the second button. And when you click the button again, it will change to the text and hyperlink of the first button.

    I know I'm being really confusing here (while rereading what i typed, even I myself was confused) but i hope I can get my point out to you. Thanks a lot for your help!

  • #2
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    Any help please!

  • #3
    Regular Coder
    Join Date
    Mar 2008
    Posts
    301
    Thanks
    2
    Thanked 30 Times in 30 Posts
    I think all modern browsers recognize "inline-block" for CSS "display".

    So if text2 is positioned over text1, and text2 starts out hidden, your button would just toggle text2 between display:none and display:inline-block.

    Just use the 'conditional operator', the inline branch,

    onclick="var d2=document.getElementById('text2');d2.style.display = d2.style.display!=='inline-block' ? 'inline-block' : 'none';"

    [Better though to assign in your script to the 'click' button using the setAttribute() method than hardcode into the HTML page, as a general rule.]


  •  

    Posting Permissions

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