By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,625 Members | 1,604 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,625 IT Pros & Developers. It's quick & easy.

Can I change a p into a textarea?

P: n/a
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
Jun 27 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On May 29, 8:36 pm, "samsli...@gmail.com" <samsli...@gmail.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

http://www.w3.org/TR/DOM-Level-2-Cor...l#ID-745549614

Peter
Jun 27 '08 #2

P: n/a
On May 29, 9:10*pm, Peter Michaux <petermich...@gmail.comwrote:
On May 29, 8:36 pm, "samsli...@gmail.com" <samsli...@gmail.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

http://www.w3.org/TR/DOM-Level-2-Cor...l#ID-745549614

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?
Jun 27 '08 #3

P: n/a
sa*******@gmail.com wrote:
On May 29, 9:10 pm, Peter Michaux <petermich...@gmail.comwrote:
>On May 29, 8:36 pm, "samsli...@gmail.com" <samsli...@gmail.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>
Jun 27 '08 #4

P: n/a
On May 29, 10:43 pm, "samsli...@gmail.com" <samsli...@gmail.com>
wrote:
On May 29, 9:10 pm, Peter Michaux <petermich...@gmail.comwrote:
On May 29, 8:36 pm, "samsli...@gmail.com" <samsli...@gmail.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
http://www.w3.org/TR/DOM-Level-2-Cor...l#ID-745549614
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.createElement('textarea');
ta.rows = '10';
ta.cols = '70';
ta.innerHTML = el.innerHTML;
el.parentNode.replaceChild(ta, el);
}
</script>

</head>
<body>

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

</body>
</html>

Peter
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.