#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Posts
    181
    Rep Power
    13

    increase size textarea with JavaScript and PHP


    I have textarea to provide user add article, if user seem font too small in textarea, user can click button to increase font size to 16 px or increase to 10 px, and user can preview article by click preview

    I'm modify my code to view simple like this
    PHP Code:
    <html>
    <head>
    <style>
    TEXTAREA {
    font-family:MS Sans Serif;font-size:10px; 
    }
    </style></head>
    <body>

    <form action="<? echo $PHP_SELF?>" method="post" name='b'>
    <form name='b'> 
    <table width=100%>
    <tr><td>
            <textarea name="a" cols=100 rows=20></textarea> <br><br>
    </td></tr>
    <tr><td>
            <input type="button" value='increase font' onClick='document.b.a.style.fontSize = 16'>
            <input type="button" value='decrease font' onClick='document.b.a.style.fontSize = 10'><br>

    <input type=submit value=preview>
    <input type=submit value=add>
    </td></tr>
    </table>
    </form> 

    </body></html>
    I have 2 problem with this code
    1. If i'm click increase font to 16 px, the size of text is exceed border of table. How should I do?
    2. If I'm increase size to 16px and click preview, when it load again, font it textarea remain 10px (instead 16 px) How shold I do?

    Thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jul 2001
    Location
    Oslo
    Posts
    1,516
    Rep Power
    14
    You can't modify the current DOM like that, when you post a textarea it will just post pure text anyway. Either you will have to use tags (like the ones used here, which is kinda crap), or you'll have to write your own little editor using editable elements and execCommand() (IE5.5). Some info on this can be found here:
    http://msdn.microsoft.com/library/de...de07232001.asp

    And here:
    http://msdn.microsoft.com/library/de...itdesigner.asp
    --
    Regards
    André Nęss

    Puritanism: The haunting fear that someone, somewhere may be having fun
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Location
    London, UK
    Posts
    1
    Rep Power
    0
    or you'll have to write your own little editor using editable elements and execCommand() (IE5.5). Some info on this can be found here:
    Oh, that'll be nice and accessible to people using any other browser won't it!? Not to mention people who may not rely on sight navigate pages.

    (The graphical smily here was 'easy' to add for example. I looked at the source of the page, read the javascript and added the relavent text to the text input by hand. Grrr... how I hate javascript!)

IMN logo majestic logo threadwatch logo seochat tools logo