Can I change a p into a textarea?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • samslists@gmail.com

    Can I change a p into a textarea?

    Hi...

    I've seen code which changes a paragraph into a textarea (to allow it
    to be edited)...by creating a brand new text area, inserting that into
    the dom at the right place, and deleting the paragraph from the dom.

    I.e. http://www.quirksmode.org/dom/cms.html

    What I'm wondering is: is there some way to simplify this? Can I
    just tell the paragraph to become a textarea?

    I'm pretty sure the answer is no...but I want to make sure there is no
    way.

    Thanks
  • Peter Michaux

    #2
    Re: Can I change a p into a textarea?

    On May 29, 8:36 pm, "samsli...@gmai l.com" <samsli...@gmai l.comwrote:
    Hi...
    >
    I've seen code which changes a paragraph into a textarea (to allow it
    to be edited)...by creating a brand new text area, inserting that into
    the dom at the right place, and deleting the paragraph from the dom.
    >
    I.e.http://www.quirksmode.org/dom/cms.html
    >
    What I'm wondering is: is there some way to simplify this? Can I
    just tell the paragraph to become a textarea?
    >
    I'm pretty sure the answer is no...but I want to make sure there is no
    way.
    I believe the answer is no. The tagName attribute is readonly



    Peter

    Comment

    • samslists@gmail.com

      #3
      Re: Can I change a p into a textarea?

      On May 29, 9:10 pm, Peter Michaux <petermich...@g mail.comwrote:
      On May 29, 8:36 pm, "samsli...@gmai l.com" <samsli...@gmai l.comwrote:
      >
      Hi...
      >
      I've seen code which changes a paragraph into a textarea (to allow it
      to be edited)...by creating a brand new text area, inserting that into
      the dom at the right place, and deleting the paragraph from the dom.
      >>
      What I'm wondering is:  is there some way to simplify this?  Can I
      just tell the paragraph to become a textarea?
      >
      I'm pretty sure the answer is no...but I want to make sure there is no
      way.
      >
      I believe the answer is no. The tagName attribute is readonly
      >

      >
      Peter
      Thank you for the response.

      Ahh...it's a tagname. I was wondering what it was called. Seems a
      shame that you can't do this.

      Is there a library that creates a new element and deletes the old
      element as if you had just changed the tagname? So I can get the same
      behavior transparently?

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: Can I change a p into a textarea?

        samslists@gmail .com wrote:
        On May 29, 9:10 pm, Peter Michaux <petermich...@g mail.comwrote:
        >On May 29, 8:36 pm, "samsli...@gmai l.com" <samsli...@gmai l.comwrote:
        >>I've seen code which changes a paragraph into a textarea (to allow it
        >>to be edited)...by creating a brand new text area, inserting that into
        >>the dom at the right place, and deleting the paragraph from the dom.
        >>I.e.http://www.quirksmode.org/dom/cms.html
        >>What I'm wondering is: is there some way to simplify this? Can I
        >>just tell the paragraph to become a textarea?
        >>I'm pretty sure the answer is no...but I want to make sure there is no
        >>way.
        >I believe the answer is no. The tagName attribute is readonly
        >>
        >http://www.w3.org/TR/DOM-Level-2-Cor...l#ID-745549614
        >
        Thank you for the response.
        >
        Ahh...it's a tagname.
        No, the attribute of the interface and the property of the implemented
        object is called `tagName'.
        I was wondering what it was called.
        The attribute/property describes the type of the element represented by
        the DOM object.
        Seems a shame that you can't do this.
        It isn't generally reasonable to do this. Different elements follow
        different rules.
        Is there a library that creates a new element and deletes the old
        element as if you had just changed the tagname? So I can get the same
        behavior transparently?
        Probably yes.


        PointedEars
        --
        Use any version of Microsoft Frontpage to create your site.
        (This won't prevent people from viewing your source, but no one
        will want to steal it.)
        -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

        Comment

        • Peter Michaux

          #5
          Re: Can I change a p into a textarea?

          On May 29, 10:43 pm, "samsli...@gmai l.com" <samsli...@gmai l.com>
          wrote:
          On May 29, 9:10 pm, Peter Michaux <petermich...@g mail.comwrote:
          >
          >
          >
          On May 29, 8:36 pm, "samsli...@gmai l.com" <samsli...@gmai l.comwrote:
          >
          Hi...
          >
          I've seen code which changes a paragraph into a textarea (to allow it
          to be edited)...by creating a brand new text area, inserting that into
          the dom at the right place, and deleting the paragraph from the dom.
          >>
          What I'm wondering is: is there some way to simplify this? Can I
          just tell the paragraph to become a textarea?
          >
          I'm pretty sure the answer is no...but I want to make sure there is no
          way.
          >
          I believe the answer is no. The tagName attribute is readonly
          >>
          Peter
          >
          Thank you for the response.
          >
          Ahh...it's a tagname. I was wondering what it was called. Seems a
          shame that you can't do this.
          >
          Is there a library that creates a new element and deletes the old
          element as if you had just changed the tagname? So I can get the same
          behavior transparently?
          You could write your own. Here is an incomplete starter example:

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
          "http://www.w3.org/TR/html4/strict.dtd">

          <html>
          <head>

          <title>Page Title</title>

          <script type="text/javascript">
          function change(el) {
          var ta = document.create Element('textar ea');
          ta.rows = '10';
          ta.cols = '70';
          ta.innerHTML = el.innerHTML;
          el.parentNode.r eplaceChild(ta, el);
          }
          </script>

          </head>
          <body>

          <p onclick="change (this);">
          click <b>me</bto <i>change</ime to a textarea
          </p>

          </body>
          </html>

          Peter

          Comment

          Working...