如何在HTML中的另一个textarea中嵌入textarea?

时间:2022-03-17 20:12:17

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.

有没有办法在另一个textarea块中嵌入textarea块但不渲染内部textarea并保留外部textarea?我无法修改内部textarea。对于外部区块而言,可能比使用textarea更好。我需要一些能在POST上提交内容的东西。将内侧尖括号转换为实体不是一个选项,因为我想在外部textarea中保留html。

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>

9 个解决方案

#1


23  

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.

说真的,编码html是唯一的选择。一旦发布,您可以随时解码它/在服务器端代码中执行任何操作。

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

#2


3  

I've have adequate success wrapping the textarea in a paragraph tag. These one worked for me:

我已经有足够的成功将textarea包装在段落标记中。这些对我有用:

<p style="margin:0;"><textarea rows="1" readonly="readonly" id="summary" name="Summary" ></textarea></p>

<p><textarea name="Note"></textarea></p>

This one didn't work for me:

这个对我不起作用:

<p><textarea rows="4" name="In_Honor_Address" class="blockInput"></textarea></p>

Haven't figured out what the difference is between one of these working and the other not, but worth a try.

还没弄清楚其中一个工作与另一个工作之间有什么不同,但值得一试。

#3


2  

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

不,你不能这样做。 textarea中唯一有效的是文本。这是一个textarea。 :-)

#4


1  

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>

#5


0  

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>

#6


0  

Try a hidden form field.

尝试隐藏的表单字段。

#7


0  

Have you considered using FckEditor?

你考虑过使用FckEditor吗?

#8


0  

Heres your solution:

继承人你的解决方案:

Replace all <'s and >'s with

将所有<'s和>替换为

&lt; and &gt;

#9


0  

I recently had the same issue and after searching high and low over the net for an answer i resolved it by putting the inside form into a seamless iframe.

我最近有同样的问题,在网上搜索高低后得到一个答案我通过将内部表单放入一个无缝的iframe来解决它。

#1


23  

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.

说真的,编码html是唯一的选择。一旦发布,您可以随时解码它/在服务器端代码中执行任何操作。

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

#2


3  

I've have adequate success wrapping the textarea in a paragraph tag. These one worked for me:

我已经有足够的成功将textarea包装在段落标记中。这些对我有用:

<p style="margin:0;"><textarea rows="1" readonly="readonly" id="summary" name="Summary" ></textarea></p>

<p><textarea name="Note"></textarea></p>

This one didn't work for me:

这个对我不起作用:

<p><textarea rows="4" name="In_Honor_Address" class="blockInput"></textarea></p>

Haven't figured out what the difference is between one of these working and the other not, but worth a try.

还没弄清楚其中一个工作与另一个工作之间有什么不同,但值得一试。

#3


2  

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

不,你不能这样做。 textarea中唯一有效的是文本。这是一个textarea。 :-)

#4


1  

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>

#5


0  

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>

#6


0  

Try a hidden form field.

尝试隐藏的表单字段。

#7


0  

Have you considered using FckEditor?

你考虑过使用FckEditor吗?

#8


0  

Heres your solution:

继承人你的解决方案:

Replace all <'s and >'s with

将所有<'s和>替换为

&lt; and &gt;

#9


0  

I recently had the same issue and after searching high and low over the net for an answer i resolved it by putting the inside form into a seamless iframe.

我最近有同样的问题,在网上搜索高低后得到一个答案我通过将内部表单放入一个无缝的iframe来解决它。