tags:

views:

424

answers:

6

Is there a way to embed a textarea block inside of another textarea block but not render the inside textarea and preserve the outside textarea? I cannot modify the inside textarea. Perhaps there is something better to use for the outside block than a textarea. I need something that will submit its contents at POST. Converting the inside angle brackets to entities is not an option since I want to preserve the html inside the outer textarea.

Non-working Sample Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>Test Embedded textareas</title>
</head>
<body>
    <form method="POST">
        <textarea>
            Outside Textarea
            <textarea>Inside Textarea</textarea>
        </textarea>
        <input type="submit" value="Submit" />
    </form>
</body>
</html>
+1  A: 

Try this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>Test Embedded textareas</title>
</head>
<body>
    <textarea>
        Outside Textarea

    </textarea>
<textarea style="margin-top:-250px; height:250px;">Inside Textarea</textarea>
</body>
</html>
CodeJoust
didn't work for me in FF 3.5. Also, I forgot to mention that I don't want to modify the inside textarea. I'll edit the question to clarify.
John Scipione
A: 

Why?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>Test Embedded textareas</title>
</head>

<style type="text/css">
    #outside { position:absolute; top:0; left:0; z-index:0; width:400px;
        height:400px }
    #inside  { position:absolute; top:100px; left:100px; z-index:1; 
        width:200px; height:200px; }
</style>

<body>

    <div>

        <textarea id="outside" rows="10" cols="80">
            Outside Textarea
        </textarea>

        <textarea id="inside" rows="5" cols="60" readonly>
            Inside Textarea
        </textarea>

    </div>

</body>
</html>
Sinan Ünür
well done but no good, inner textarea must be inside outer block and cannot modify inner textarea
John Scipione
A: 

Try a hidden form field.

Daniel A. White
+1  A: 

No. You can't do it. The only thing valid inside of a textarea is text. It's a textarea. :-)

Jesse Weigert
I only want to put text in my textarea, specifically the text </textarea>, but it won't let me do it!
John Scipione
No, you're trying to put the text </textarea> in your text area. Excluding those entities are what encoding is for.
eaolson
+9  A: 

Yo dawg.

Seriously, encoding the html is the only option. You can always decode it/do whatever in your server-side code once it gets posted.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>Test Embedded textareas</title>
</head>
<body>
    <form method="POST">
        <textarea>
            Outside Textarea
            &lt;textarea&gt;Inside Textarea&lt;/textarea&gt;
        </textarea>
        <input type="submit" value="Submit" />
    </form>
</body>
</html>
Chetan Sastry
I heard you like textareas, so I put a textarea in your textarea so you can edit your textarea while you edit your textarea?
Chris Sobolewski
You must convert to entities. The only other (ick) solution might be to use JavaScript to convert the brackets and populate the text area, and then reconvert on submit.
Jim Zajkowski
I begrudgingly accept this answer to be truth.
John Scipione
A: 

Have you considered using FckEditor?

Paul Sasik
Yes I have considered using an editor like FckEditor but I don't want a WYSIWYG editor. I just want a plain old text editor inside of an HTML textarea. I am using EditArea Javascript to style the html code though. Check it out here: http://www.cdolivet.com/index.php?page=editArea
John Scipione