SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    May 2002
    Location
    USA
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Creating Bold, Italic, and Underline buttons with PHP.

    I was wondering how to go about making when a user clicks on a link or picture that I could have the HTML code appear in a textarea box. Like clicking on a picture of the letter B would print <b></b> in the textarea box. It doesn't have to be fancy, just has to work.

    Thanks!

    JRF2k
    Man can learn nothing except by going from the known to the the unknown. -- Claude Bernard

  2. #2
    SitePoint Zealot Overgrow's Avatar
    Join Date
    Jan 2001
    Location
    Your basement
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is a javascript question, best to ask elsewhere.
    Overgrow the Government: The Edge Forums
    presented by Overgrow Marijuana Magazine

    *warning: adult content

  3. #3
    SitePoint Zealot
    Join Date
    May 2002
    Location
    USA
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So there is no way to do it in PHP?
    Man can learn nothing except by going from the known to the the unknown. -- Claude Bernard

  4. #4
    SitePoint Zealot Overgrow's Avatar
    Join Date
    Jan 2001
    Location
    Your basement
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You want to perform a client-side operation so you have to use a client-side language. PHP is run on the server, not the client's browser. Javascript is the easiest solution:
    Code:
    <a href="java script:void(0);" 
    onclick="document.formname.textbox.value = document.formname.textbox.value + '<b></b>';
    document.formname.textbox.focus();">BOLD</a>
    <form name="formname">
    <textarea name="textbox"></textarea>
    </form>
    Overgrow the Government: The Edge Forums
    presented by Overgrow Marijuana Magazine

    *warning: adult content

  5. #5
    SitePoint Zealot
    Join Date
    May 2002
    Location
    USA
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I'll look into it. Thanks!
    Man can learn nothing except by going from the known to the the unknown. -- Claude Bernard

  6. #6
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For cross browser compatability I'd suggest that you use the Document Object Model (Level 2) for this.

    For some info on what the DOM can do, go off and have a browse over at www.scottandrew.com - not a bad site for beginners looking for examples, etc.


Bookmarks

Posting Permissions

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