A question about textarea

Discussion in 'Javascript' started by aaabbb16@hotmail.com, Nov 11, 2007.

  1. Guest

    the code is like following:
    <textarea cols=40 rows=10 name=n style="overflow:auto"> this is a test
    about textarea and see how it works..... </textarea>
    can i assign a variable to rows based on my contents length? or
    javascript has any internal attribute i can use?
    TIA.
    st
     
    , Nov 11, 2007
    #1
    1. Advertising

  2. VK Guest

    On Nov 11, 5:50 pm, wrote:
    > the code is like following:
    > <textarea cols=40 rows=10 name=n style="overflow:auto"> this is a test
    > about textarea and see how it works..... </textarea>
    > can i assign a variable to rows based on my contents length? or
    > javascript has any internal attribute i can use?


    Do you want to make it once on page loading or at any time after page
    loaded?
     
    VK, Nov 11, 2007
    #2
    1. Advertising

  3. Guest

    On 11 11 , 6 58 , VK <> wrote:
    > On Nov 11, 5:50 pm, wrote:
    >
    > > the code is like following:
    > > <textarea cols=40 rows=10 name=n style="overflow:auto"> this is a test
    > > about textarea and see how it works..... </textarea>
    > > can i assign a variable to rows based on my contents length? or
    > > javascript has any internal attribute i can use?

    >
    > Do you want to make it once on page loading or at any time after page
    > loaded?


    It is html builder to create a html file. The reason is my content
    change often. sometimes may be just
    one line or two, if set row=10, it wast more space.
    what I basic idea is use string length to check my contents (may use a
    function to check it), then based on that assign a var. to rows. Is
    it possible? also if the content is longer that 10 rows, use
    scrollbar.
     
    , Nov 11, 2007
    #3
  4. VK Guest

    On Nov 11, 6:28 pm, wrote:
    > It is html builder to create a html file. The reason is my content
    > change often. sometimes may be just
    > one line or two, if set row=10, it wast more space.
    > what I basic idea is use string length to check my contents (may use a
    > function to check it), then based on that assign a var. to rows. Is
    > it possible? also if the content is longer that 10 rows, use
    > scrollbar.


    >From the usability point of view your idea doesn't sound appealing:

    one often opens a small HTML document to make it big ;-) - say to
    replace the default template with her own code. By shrinking the
    default textarea you are complicating the future editing. It is also
    silly to ask before page load "are you making a few changes in this
    puny text or it's gonna get big?" or something. So I would serve some
    default "fit-the-most" textarea, say cols="72" rows="16", and maybe I
    would provide a "maximize" button in the menu to make the textarea as
    big as possible.
    In either case you are manipulating .cols and .rows property of
    textarea to change its size after the page finished loading, like

    <form method="post" action="">
    <textarea name="HTMLSource" cols="72" rows="16"></textarea>
    <input type="button" value="Extent" onclick="
    this.form.HTMLSource.rows = 20;
    ">
    </form>
     
    VK, Nov 11, 2007
    #4
  5. Guest

    On 11 11 , 7 43 , VK <> wrote:
    > On Nov 11, 6:28 pm, wrote:
    >
    > > It is html builder to create a html file. The reason is my content
    > > change often. sometimes may be just
    > > one line or two, if set row=10, it wast more space.
    > > what I basic idea is use string length to check my contents (may use a
    > > function to check it), then based on that assign a var. to rows. Is
    > > it possible? also if the content is longer that 10 rows, use
    > > scrollbar.
    > >From the usability point of view your idea doesn't sound appealing:

    >
    > one often opens a small HTML document to make it big ;-) - say to
    > replace the default template with her own code. By shrinking the
    > default textarea you are complicating the future editing. It is also
    > silly to ask before page load "are you making a few changes in this
    > puny text or it's gonna get big?" or something. So I would serve some
    > default "fit-the-most" textarea, say cols="72" rows="16", and maybe I
    > would provide a "maximize" button in the menu to make the textarea as
    > big as possible.
    > In either case you are manipulating .cols and .rows property of
    > textarea to change its size after the page finished loading, like
    >
    > <form method="post" action="">
    > <textarea name="HTMLSource" cols="72" rows="16"></textarea>
    > <input type="button" value="Extent" onclick="
    > this.form.HTMLSource.rows = 20;
    > ">
    > </form>


    Let me further explain it.
    I provide a textarea (say this textarea within a table tag)to content
    designer. she/he can type anything she/he wants and return back it to
    my html builder and it automatic create a standard html page and
    upload it to any viewers using IE.
    I do not give any button to IE viewers to change this page.
    just let them to view it.
    Since i can not predict content desinger how many line she/he
    write to this textarea for every time. the worst case is that content
    designer maybe write only one line. the rows i set is rows=10. so
    viewers may see this page not pretty. (for example next day this page
    may updated because content designer change content to seven lines.)
    My html builder is automatic tool. not need manual chang it. That is
    why I need to assign a var to rows attribute. or you may have diff
    solutions.
    Thanks a lot!
    st
     
    , Nov 11, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jukka K. Korpela

    Re: basic textarea question

    Jukka K. Korpela, Jul 15, 2003, in forum: HTML
    Replies:
    0
    Views:
    397
    Jukka K. Korpela
    Jul 15, 2003
  2. Mel
    Replies:
    1
    Views:
    436
    Jukka K. Korpela
    Feb 3, 2004
  3. Augustus
    Replies:
    1
    Views:
    399
    Ken Schaefer
    Sep 10, 2003
  4. Textarea Inside of a textarea

    , Feb 4, 2006, in forum: ASP General
    Replies:
    6
    Views:
    363
    Anthony Jones
    Feb 5, 2006
  5. Replies:
    1
    Views:
    357
    Bart Van der Donck
    Jul 4, 2007
Loading...

Share This Page