473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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
Jun 27 '08 #1
4 2147
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alexandre Flament | last post by:
I would like to know what change on textarea : - when user change content with keyboard - when user drag/drop some text to textarea By what change, I mean for example, this kind of event : - at...
1
by: laredotornado | last post by:
Hello, I am trying to detect whether a user entered text in a textarea or hit the delete/backspace button (thus, erasing something). Once that is detected, I would like to set "var bSaveRequired =...
4
by: delraydog | last post by:
If you've used the Google Gmail spell checker you know that it 'changes' the text area to another type of control that lets them show hyperlinks for the incorrect words. How does Google change the...
3
by: Fluffy Convict | last post by:
I am trying to write a script that changes a textarea wrap realtime, basically like you can switch to and from "wordwrap" in Microsofts Notepad. Because of a bug...
4
by: TJS | last post by:
can the rows and columns of a textarea element with an id be changed on the fly ? if so is there an example ?
4
by: ANTISPAM_garycnew_ANTISPAM | last post by:
I am trying to figure out the best way to change a form's action based on a single text input event. I have a search form within a larger form and would like to allow users to use the enter key...
6
by: libsfan01 | last post by:
hi all! is it possible to change an element type with javacript for example onclick to change a text box to a hidden element or to a textarea? kind regards marc
1
by: chrisdr | last post by:
I found this code in a previous post but I am not able to get this to work for me... I am trying to dynamically change an element's type from textbox to textarea with an event. Actually in my code...
10
by: waltapp | last post by:
Hello, I am a new programmer and I am working on a school project. I am being instructed to move up then down the dom. My parent is demo.html then a frameset and then another frameset within the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.