Manipulating a textarea

Discussion in 'Javascript' started by Floortje, Oct 22, 2008.

  1. Floortje

    Floortje Guest

    Hi, for the past few days now im trying to find some info on how to
    manipulate textarea's with javascript. Im trying to add content when a
    certain element is clicked or alter content if another is clicked (wrap
    ubb tags around it).

    I have found quite a few examples but they either dont work on all major
    browsers (example
    http://phphulp.jorendewit.nl/snippets/javascript/ubb.php) or they are
    complete WYSIWYG editors and have quite a large footprint (as most
    people on the www just recommend tinymce).

    Does anyone know of an example that does the trick or can anyone push me
    in the right direction ?

    Floortje
    Floortje, Oct 22, 2008
    #1
    1. Advertising

  2. Floortje

    David Mark Guest

    On Oct 22, 8:44 am, Floortje <> wrote:
    > Hi, for the past few days now im trying to find some info on how to
    > manipulate textarea's with javascript. Im trying to add content when a
    > certain element is clicked or alter content if another is clicked (wrap
    > ubb tags around it).


    Wrap "ubb tags" around what? A textarea can only contain text.

    >
    > I have found quite a few examples but they either dont work on all major
    >   browsers (examplehttp://phphulp.jorendewit.nl/snippets/javascript/ubb..php) or they are


    No shock there.

    > complete WYSIWYG editors and have quite a large footprint (as most
    > people on the www just recommend tinymce).


    Most people on the www are pinheads.

    >
    > Does anyone know of an example that does the trick or can anyone push me
    > in the right direction ?


    To set the value of a textarea? No trick required. Set its value
    property.
    David Mark, Oct 22, 2008
    #2
    1. Advertising

  3. Floortje

    Floortje Guest

    David Mark schreef:
    > On Oct 22, 8:44 am, Floortje <> wrote:
    >> Hi, for the past few days now im trying to find some info on how to
    >> manipulate textarea's with javascript. Im trying to add content when a
    >> certain element is clicked or alter content if another is clicked (wrap
    >> ubb tags around it).

    >
    > Wrap "ubb tags" around what? A textarea can only contain text.


    wrap ubb tags around the text in the textarea

    <snip>
    >> Does anyone know of an example that does the trick or can anyone push me
    >> in the right direction ?

    >
    > To set the value of a textarea? No trick required. Set its value
    > property.


    Yup but how do I change the value and add / alter texted based ont he
    curcur position inside the textarea.
    Floortje, Oct 22, 2008
    #3
  4. Floortje <> wrote:
    ^^^^^^^^^^^^
    I won't, because I can't. And that's why you will get no answer here, too.


    PointedEars
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
    Thomas 'PointedEars' Lahn, Oct 22, 2008
    #4
  5. Floortje

    David Mark Guest

    On Oct 22, 6:53 pm, Thomas 'PointedEars' Lahn <>
    wrote:
    > Floortje <> wrote:
    >
    >           ^^^^^^^^^^^^
    > I won't, because I can't.  And that's why you will get no answer here, too.
    >


    Well said.
    David Mark, Oct 23, 2008
    #5
  6. Floortje

    Rik Wasmus Guest

    On Thu, 23 Oct 2008 00:14:07 +0200, Floortje <> wrote:

    > David Mark schreef:
    >> On Oct 22, 8:44 am, Floortje <> wrote:
    >>> Hi, for the past few days now im trying to find some info on how to
    >>> manipulate textarea's with javascript. Im trying to add content when a
    >>> certain element is clicked or alter content if another is clicked (wrap
    >>> ubb tags around it).

    >> Wrap "ubb tags" around what? A textarea can only contain text.

    >
    > wrap ubb tags around the text in the textarea
    >
    > <snip>
    >>> Does anyone know of an example that does the trick or can anyone push
    >>> me
    >>> in the right direction ?

    >> To set the value of a textarea? No trick required. Set its value
    >> property.

    >
    > Yup but how do I change the value and add / alter texted based ont he
    > curcur position inside the textarea.


    To rephrase (probably still in far from fluent english):
    "How can I get only the currently selected and/or the cursor position in a
    textarea, and how can I replace this and only this text, leaving the not
    selected contents of the textarea intact"

    Never needed to dabble with that, but at least phrased that way one gets
    less semantics fanatics excited :p
    --
    Rik
    Rik Wasmus, Oct 23, 2008
    #6
  7. Floortje

    David Mark Guest

    On Oct 22, 6:14 pm, Floortje <> wrote:
    > David Mark schreef:
    >
    > > On Oct 22, 8:44 am, Floortje <> wrote:
    > >> Hi, for the past few days now im trying to find some info on how to
    > >> manipulate textarea's with javascript. Im trying to add content when a
    > >> certain element is clicked or alter content if another is clicked (wrap
    > >> ubb tags around it).

    >
    > > Wrap "ubb tags" around what?  A textarea can only contain text.

    >
    > wrap ubb tags around the text in the textarea


    Okay, I Googled ubb (sic) tags. Yes, you can use them with a
    textarea; and no, tinyMCE would not have been a good choice.

    >
    > <snip>
    >
    > >> Does anyone know of an example that does the trick or can anyone push me


    Not a good one.

    > >> in the right direction ?


    https://developer.mozilla.org/en/NsISelection
    David Mark, Oct 23, 2008
    #7
  8. Floortje

    Floortje Guest

    Rik Wasmus wrote:

    > To rephrase (probably still in far from fluent english):
    > "How can I get only the currently selected and/or the cursor position in
    > a textarea, and how can I replace this and only this text, leaving the
    > not selected contents of the textarea intact"
    >
    > Never needed to dabble with that, but at least phrased that way one gets
    > less semantics fanatics excited :p


    hi Rik,

    Thx that is what I mean :)

    Floortje
    Floortje, Oct 23, 2008
    #8
  9. Floortje

    Floortje Guest

    Floortje, Oct 23, 2008
    #9
    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. Augustus
    Replies:
    1
    Views:
    348
    Ken Schaefer
    Sep 10, 2003
  2. Textarea Inside of a textarea

    , Feb 4, 2006, in forum: ASP General
    Replies:
    6
    Views:
    324
    Anthony Jones
    Feb 5, 2006
  3. Greg Scharlemann

    manipulating text in a textarea

    Greg Scharlemann, Dec 18, 2005, in forum: Javascript
    Replies:
    4
    Views:
    112
    Greg Scharlemann
    Dec 19, 2005
  4. Daniel Pitts

    Manipulating selected text in a TEXTAREA...

    Daniel Pitts, Nov 21, 2006, in forum: Javascript
    Replies:
    2
    Views:
    75
    Jonas Raoni
    Nov 21, 2006
  5. Replies:
    1
    Views:
    306
    Bart Van der Donck
    Jul 4, 2007
Loading...

Share This Page