1. #1
    Deleted

    HTML buttons - How can I use them to change text?

    Theres a lot of well educated chaps on MMO Champ so I thought i'd give this an ask,

    Basically I want to press a button and when I do so it changes the text in the middle of the screen to a different piece of text depending on which button I press (I guess I could just make them link to a webpage that is exactly the same just different text but that's boring) I'm pretty much a novice when it comes to HTML and i've only been learning it for a few weeks so i'm pretty much falling over at every obstacle.

    I'm using notepad++ and my buttons code is:

    <button type="button" style="width:120;height:130" style="background-color:lightblue" href="Assignment_1_notes[1].doc">
    <img src="vb_icon.jpg" alt="Event Driven" />
    <br />Event Driven Programming</button>
    Also if anyone knows how I can align my text into the center and the buttons at the left hand side of the screen that would be greatly appreciated. Screenshot is here: http://sadpanda.us/images/657886-CQZL1G0.png

  2. #2
    Deleted
    The best way to have text change in your button is if the text was an image. Then with css you could use stuff like #buttonid:active{background-image:etc;} this loads the image if you click and hold your mousebutton.
    If you really want it to be text you could best use javascript. Could try to make something for yah if you like:3

    For the text in the middle and buttons on the left. Wrap your buttons in <div style="float:left">buttons </div> and your text in<div>text</div>. Play around with that:3

  3. #3
    Blademaster sipCider's Avatar
    10+ Year Old Account
    Join Date
    Jul 2011
    Location
    On the right coast - USA
    Posts
    34
    For the click text changes take a look at this InnerHTML tutorial, it's really easy.
    http://www.tizag.com/javascriptT/jav...-innerHTML.php

    For the alignment you will need to get some CSS to help.
    This should have the example that will work for you, possibly number 5 or 6.
    http://www.barelyfitz.com/screencast...s/positioning/

    -HTH
    Post may contain sarcasm:
    Discontinue use if experiencing mood swings, nausea or elevated blood pressure.

  4. #4
    Deleted
    Thanks for going to the effort of finding tutorials, going to experiment with it Much appreciated.

  5. #5
    Legendary! llDemonll's Avatar
    15+ Year Old Account
    Join Date
    Apr 2008
    Location
    Washington
    Posts
    6,582
    Search for how to show and hide divs. I would recommend against this though because when people go to your page they are going to have to load everything instead of just the page they want to view

    There is probably a way you can use JavaScript to make the center content load and change only on demand when requested instead of all at once when they first visit
    "I'm glad you play better than you read/post on forums." -Ninety
    BF3 Profile | Steam Profile | Assemble a Computer in 9.75 Steps! | Video Rendering Done Right

Posting Permissions

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