473,779 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2177
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

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...@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.
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...@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>
Jun 27 '08 #4
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.
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.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
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2837
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 offset 153 - user add this text "azerty" Is there a way to do it with ECMA ? or perhaps with specific extension of mozilla or IE ?
1
2538
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 = true;". It would be great if this function worked cross-browser -- IE 6.0 and Firefox. Any ideas are greatly appreciated, - Dave
4
2293
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 textarea? And what do they change it to? I know it should be pretty simple, I just have no clue because I'm fairly new to DHTML. Any examples would be greatly appreciated. Thanks! Cliff. delraydog@gmail.com
3
6776
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 (https://bugzilla.mozilla.org/show_bug.cgi?id=302710), FireFox does not listen to the textarea.wrap = 'soft' command. Because I want the script to be cross-browser compatible, someone suggested to remove and immediately add a node to the DOM, so I now have: ...
4
4261
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
6509
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 within the search text input without submitting the larger form. I discovered the onKeyPress event and the keyCode for the Enter Key (13). Now I need to figure out a way to pass the result of the onKeyPress to the larger form's onSubmit event to...
6
12774
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
8959
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 i'm using a onClick event on a checkbox, but this is the original code exactly the way it was in the previous post... I tried to use it as it is and it errors out... Any input on how to make this code work or any other suggestions on how to accomplish...
10
3450
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 frameset. I have figured out how to get up to the parent and then down to the first frameset and change the rows attribute. However I am stuck on getting to the next level, I am required to change the height of the second frameset textarea to 300 pixels....
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9930
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.