SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    TEXT formatting using JAVASCRIPT

    i am making a content manager, i want to be able to have the user format text with bold, italics, fontsize, color, etc within the text field window, kind of like the page here where we post topics and reply, any ideas where i can find any free scripts for this?

    thanks
    turn your site into a lead generating and money making machine.
    WE CAN SHOW YOU HOW
    Logical Media Web Design

  2. #2
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Make one. Something like this is basic but I am new to JavaScript so...
    Code:
    <script>
    function insertBold()
    {
       document.getElementById('text').value = document.getElementById('text').value + '<b></b>';
    }
    </script>
    
    <button onClick="insertBold()">Bold</button>
    <textarea id='text'></textarea>

  3. #3
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The increment operator makes this easier. Add a parameter and you're doing better
    Code:
    <script type="text/javascript">
    function insertInline( tag )
    {
       document.getElementById('text').value += '<' + tag + '></' + tag + '>';
    }
    </script>
    
    <button onClick="insertInline('b')">Bold</button>
    <button onClick="insertInline('i')">Italic</button>
    <button onClick="insertInline('u')">Underline</button>
    I think you get the idea
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  4. #4
    SitePoint Member
    Join Date
    Apr 2002
    Location
    New Zealand
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might be interested in this article: http://www.oreillynet.com/pub/a/java...s_toolbar.html

    Abhishek

  5. #5
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cool thanks i will check them out ,,,
    turn your site into a lead generating and money making machine.
    WE CAN SHOW YOU HOW
    Logical Media Web Design

  6. #6
    Froot r gewd SubKamran's Avatar
    Join Date
    May 2002
    Location
    North Star State
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Note that "getElementById" is not supported by netscape (at least when I used it it wasn't, it was Netscape 7).

    Instead do:

    Code:
    document.FORM_NAME.FORM_FIELD.value = lalalalal
    "Sometimes little is more."
    Kamran A
    Web Dev/Designer
    Keyboard not found: Please Press F1 to Continue

  7. #7
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    check here......

    you will see the line to check for NETSCAPE6

    this.ns6 = document.getElementById && !document.all;

    Keep checking the facts cos they keep changing!!!
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  8. #8
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    sorry

    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  9. #9
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It works just fine in NS7, but make sure your form element actually has an ID, and not just a NAME
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  10. #10
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    I have Netscape 6.1 and getElementById works fine. I use it to empty a textarea and when I click the button the textarea is empty...

  11. #11
    SitePoint Zealot superbrava's Avatar
    Join Date
    Aug 2001
    Location
    Indianapolis, IN
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how would you say view the formatted text in the text box you are writing your content in though? is there a way that the textarea can show you formatted text and the html?
    Steve v3.2.2 running on LocalSuck port 80

  12. #12
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Try adding this attribute to the <textarea> tag.
    Code:
    <textarea datatoformat='html'></textarea>
    I really have no idea what it does but I've seen it before so have a try


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
  •