SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    increase font size in textarea when click button

    I have this code to config font in textarea
    PHP Code:
    <head>
    <
    style>
    TEXTAREA {
    font-family:MS Sans Serif;font-size:10px
    }
    </
    style></head
    I'm initialize font=10 px.
    I want to create a button that,
    If user feel that font in textarea is too small, user can click button and font in textarea will increase to 14px.

    How can I write code to do this?

    Thanks for reply.
    Last edited by itsource; Nov 10, 2001 at 05:30.
    I live in Thailand. My English grammar not well.

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi itsource,

    <form name='b'>
    <textarea name="a"></textarea>
    <input type="button" value='change font' onClick='document.b.a.style.fontSize = 16')
    </form>

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  3. #3
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Vincent Puglia but I have little problem with this

    My code again
    PHP Code:
    <html>
    <
    head>
    <
    style>
    TEXTAREA {
    font-family:MS Sans Serif;font-size:10px
    }
    </
    style></head>
    <
    body>

    <
    form name='b'
    <
    textarea name="a" cols=100 rows=20></textarea> <br><br>
    <
    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'>
    </
    form

    </
    body></html
    (I'm fix textarea cols=100 and rows=20) When I'm click button to increase font. The area of Textarea is also increase and overlap all button.

    How to I prevent this? Is any way to fix size and area of textarea?
    I live in Thailand. My English grammar not well.

  4. #4
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    (I'm fix textarea cols=100 and rows=20) When I'm click button to increase font. The area of Textarea is also increase and overlap all button.

    How to I prevent this? Is any way to fix size and area of textarea? [/B]
    Contain both in different rows/columns of a table. This will allow both to move by themselves.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  5. #5
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much.
    I live in Thailand. My English grammar not well.

  6. #6
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have more problem.

    1. When I use table and increase font, yes textarea not overlap button. but textarea increase size and exceed border of table so I cannot see some part of textarea because table border is on top.

    2. I have more button, preview button, when I click preview button I can view detail that type in textarea and also still edit detail in textarea (like sitepoint). The problem is if I increase font size and click preview( I use PHP_SELF; ) when page reload again, the font still decrease not increase.

    Anyone help please?
    Last edited by itsource; Nov 11, 2001 at 22:54.
    I live in Thailand. My English grammar not well.

  7. #7
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by itsource
    I have more problem.

    1. When I use table and increase font, yes textarea not overlap button. but textarea increase size and exceed border of table so I cannot see some part of textarea because table border is on top.

    2. I have more button, preview button, when I click preview button I can view detail that type in textarea and also still edit detail in textarea (like sitepoint). The problem is if I increase font size and click preview( I use PHP_SELF; ) when page reload again, the font still decrease not increase.

    Anyone help please?
    Do you have absoult cell sizes <td width=50px>. Cause that will stay that size. Make it flexible <td width="10%">


    It is turning into a php question. Are you sending the variables with the link. hmmm
    <a href="blah.php?textsize=10">reload</a>

    And then querying on the reload to see if it was predefined?
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  8. #8
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I still have same problem whether set width=10% or width=100%

    In php question. I don't know how to write code. Can you show me correct code?
    My code now is
    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'> 
    <textarea name="a" cols=100 rows=20></textarea> <br><br>
    <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>
    </form> 

    </body></html>
    Thank you.
    I live in Thailand. My English grammar not well.

  9. #9
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi itsource,

    I placed your fields within a table and when the font was resized, the textarea did not overlap into the other cells. It did, however, lose its right and bottom boundaries into the netherworld, which means you lose the textarea's scrollbars.

    Since I do not know what is in on the page with the code you posted, I can only provide some general suggestions: place the textarea within its own popUp window (winTextArea = window.open(....) ) or a div. And change the font changes appropriately (windTextArea.document.b.a.... or document.all[divID].b.a....)

    Also, please note that the code I provided is IE specific. It will not work with NN4.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


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
  •