将javascrpt插入textarea? [英] insert javascrpt into textarea?

查看:63
本文介绍了将javascrpt插入textarea?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个针对强盗语言的翻译程序。


i希望用户输入到顶部窗口然后显示

加密或解密底部的窗口。


i目前正在尝试通过python / webpy webapp执行此操作但是已经

告诉它可以用javascript完成。


我该怎么做?我无法从w3schools中找到它

教程。

我可以用javascript来调用另一个文件吗?或者我必须在下面的html文件中进行

翻译?它可能变得非常混乱...


< html>

< body bgcolor =" orange">

< center>

< h1>< p>< b>强盗的语言加密/解密器!< / b>< / p>< / h1>


< form method = post>

< p>

< select name =" encdec" ;>

< option value =" encrypt"> encrypt< / option>

< option value =" decrypt"> decrypt< / option> ;

< / select>

< / p>

< textarea name =" enc"行= QUOT; 10" cols =" 50"

< / textarea>

< p>

< input type =" submit"值= [提交" />< br />

< / p>

< / form>


<表格method = post>

< textarea name =" answer"行= QUOT; 10" cols =" 50">


< / textarea>

< / form>


< / center>

< / body>

< / html>

解决方案

< blockquote> globalrev写道:


i有一个针对强盗语言的翻译程序。



您的Shift键出现故障。


i希望用户输入到顶部窗口然后显示

在底部窗口加密或解密。


i目前正在尝试通过python / webpy webapp执行此操作但是已经

告诉它可以用javascript完成。


我该怎么做?我无法从w3schools中找到它

教程。



这并不奇怪,因为W3Schools的人显然不知道HTML

。避免使用此网站,它不适合作为Web开发参考。


我可以使用javascript调用另一个文件吗?或者我必须在下面的html文件中进行

翻译?它可能变得非常混乱...



我在下面阅读的内容与html文件相差甚远。


< html>

< body bgcolor =" orange">



orange不是已弃用的bgcolor属性的有效值。

http://www.w3.org/TR/REC-html40/types。 html#h-6.5
http://validator.w3.org/


< center>



CSS2明天满10岁。

http://www.w3.org/TR/REC-html40/pres...ml#edef-CENTER


< h1>< p>< b>强盗的语言加密/解密器!< / b>< / p>< / H1>



无效,p元素不得包含在h1元素中。

http://www.w3.org/TR/REC -html40 / stru ... l.html#edef-H1


< form method = post>



无效,action属性是必需的。

http://www.w3.org/TR/REC-html40/inte...html# edef-FORM


< p>



语义错误的元素,我们这里不是在讨论文本的段落。如果必须,请使用

`div''

http://www.w3.org/TR/REC-html40/struct/text.html#edef-P
http://www.w3。 org / TR / REC-html40 / stru .... html#edef-DIV


< select name =" encdec">



你也应该设置'size''属性。

http://www.w3.org/TR/REC-html40/inte...ml# edef-SELECT


< option value =" encrypt"> encrypt< / option>

< option value =" decrypt"> decrypt< / option>

< / select>

< / p>

< textarea名称= QUOT; ENC"行= QUOT; 10" cols =" 50"

< / textarea>

< p>

< input type =" submit"值= [提交" />< br />



你不想使用XHTML。

http://hixie.ch/advocacy/xhtml
http://hsivonen.iki.fi/xhtml-the-point/


< / p>

< / form>


< form method = post>



见上文。


< textarea name =" answer"行= QUOT; 10" cols =" 50">


< / textarea>

< / form>



您不想提交此表格的信息,因此您不需要表格

元素。


< / center>

< / body>

< / html>



至于你的问题,你可以用


< form action ="实现可选的客户端操作。 .." onsubmit =" return handleSubmit(this)">

< script type =" text / javascript">

function handleSubmit()

{

...


//如果成功

返回false;

}

< / script>

< / form>


但我强烈建议你先学习HTML。< br $>
PointedEars

-

现实主义:HTML 4.01严格

福音:XHTML 1.0 Strict

madness:XHTML 1.1 as application / xhtml + xml

- Bjoern Hoehrmann


至于你的问题,你可以实现可选的客户端 -
的边操作


>

< form action =" ..." onsubmit =" return handleSubmit(this)">

< script type =" text / javascript">

function handleSubmit()

{

...


//如果成功

返回false;

}

< / script>

< / form>


但我强烈建议你先学习HTML。



ty我知道它不是vaied html但我只是快速地把它扔掉来学习

来处理这种类型的交互。


应该在哪里插入脚本?

id我这样做,但是希望脚本写入textarea而不是,

我怎么做那样做吗?

< html>


< script type =" text / javascript">

function myfunction ()

{

alert(" HELLO");

}

< / script>


< body>

< center>


< h1>< p style =" font-family:times new roman; color:orange">

< b>强盗的语言加密器/ decrypter!< / b>

< / p>< / h1>


< p>

< select name =" encdec">

< option value =" encrypt"> encrypt< / option>

< option value ="解密">解密< /选项>

< / select>

< / p>


< textarea名称= QUOT; ENC"行= QUOT; 10" cols =" 50"

< / textarea>

s

< form>

< ;输入类型="按钮"

onclick =" myfunction()"

value =" submit">

< ; / form>


< / center>

< / body>

< / html>


globalrev写道:


>至于你的问题,你可以选择客户端操作与

< form action =" ..." onsubmit =" return handleSubmit(this)">
< script type =" text / javascript">
function handleSubmit()
{
...

//如果成功
返回false;
}
< / script>
< / form>

但我强烈建议你先学习HTML。



ty我知道它不是vaied html但我只是快速把它扔掉来学习

to处理这种类型的互动。



您不能指望无效内容有效;特别是你不能指望DOM

脚本在无效标记内和无效标记上工作。

http://diveintomark.org/archives/200..._wont_help_you


where应该插入脚本吗?



我已经写过了。


id我这样做,但希望脚本写入而不是textarea,

我该怎么做?



请阅读< http://jibbering.com/faq/>。全部,特别是

介绍部分和那里引用的材料。


< html>


< script type =" text / javascript">

function myfunction()

{

alert(" HELLO);

}

< / script>



它仍然无效。缺少DOCTYPE声明,而

'head''元素的开始和结束标记在HTML 4.01中是可选的

Transitional,'title''元素head元素不是。

http:// validator。 w3.org/


< body>

< center>



它仍然被弃用(HTML 4.01严格无效)。


< h1> < p style =" font-family:times new roman; color:orange">



以逗号分隔的`font-family''值的最后一项应该是通用的

字体系列(这里:`serif '') -

http://www.w3.org/TR/CSS2/fonts.html...ef-font-family

PointedEars

- -

任何拍下这个页面的人最好用浏览器X查看标签

a网页似乎渴望过去的糟糕时光,在Web之前,当你几乎没有机会阅读另一台b $ b计算机,另一台文字处理器或其他网络上写的文件的时候,这是
。 - Tim Berners-Lee


i have a translator-program for the robbers language.

i want the user to input into the topwindow and then display the
encryption or decryption in the bottom window.

i am currently trying to do this via a python/webpy webapp but been
told it can be done with javascript.

how would i do this? i couldnt figure it out from the w3schools
tutorial.
and can i have a javascript to call another file? or i have to do the
translation in the html-file below? it could get very cluttery...

<html>
<body bgcolor="orange">

<center>
<h1><p><b>Robber''s language encrypter/decrypter!</b></p></h1>

<form method=post>
<p>
<select name="encdec">
<option value="encrypt">encrypt</option>
<option value="decrypt">decrypt</option>
</select>
</p>
<textarea name="enc" rows="10" cols="50">
</textarea>
<p>
<input type="submit" value="submit" /><br />
</p>
</form>

<form method=post>
<textarea name="answer" rows="10" cols="50">

</textarea>
</form>

</center>
</body>
</html>

解决方案

globalrev wrote:

i have a translator-program for the robbers language.

Your Shift key is malfunctioning.

i want the user to input into the topwindow and then display the
encryption or decryption in the bottom window.

i am currently trying to do this via a python/webpy webapp but been
told it can be done with javascript.

how would i do this? i couldnt figure it out from the w3schools
tutorial.

That is unsurprising, as the W3Schools people apparently don''t know HTML
themselves. Avoid this site, it is not suitable as Web development reference.

and can i have a javascript to call another file? or i have to do the
translation in the html-file below? it could get very cluttery...

What I had to read below is very far from being a "html-file".

<html>
<body bgcolor="orange">

`orange'' is not a valid value for the deprecated `bgcolor'' attribute.

http://www.w3.org/TR/REC-html40/types.html#h-6.5
http://validator.w3.org/

<center>

CSS2 turns 10 tomorrow.

http://www.w3.org/TR/REC-html40/pres...ml#edef-CENTER

<h1><p><b>Robber''s language encrypter/decrypter!</b></p></h1>

Not Valid, the `p'' element must not be contained in the `h1'' element.

http://www.w3.org/TR/REC-html40/stru...l.html#edef-H1

<form method=post>

Not Valid, the `action'' attribute is required.

http://www.w3.org/TR/REC-html40/inte...html#edef-FORM

<p>

Semantically wrong element, we are not talking paragraphs of text here. Use
`div'' if you must.

http://www.w3.org/TR/REC-html40/struct/text.html#edef-P
http://www.w3.org/TR/REC-html40/stru....html#edef-DIV

<select name="encdec">

You should set the `size'' attribute, too.

http://www.w3.org/TR/REC-html40/inte...ml#edef-SELECT

<option value="encrypt">encrypt</option>
<option value="decrypt">decrypt</option>
</select>
</p>
<textarea name="enc" rows="10" cols="50">
</textarea>
<p>
<input type="submit" value="submit" /><br />

You don''t want to use XHTML.

http://hixie.ch/advocacy/xhtml
http://hsivonen.iki.fi/xhtml-the-point/

</p>
</form>

<form method=post>

See above.

<textarea name="answer" rows="10" cols="50">

</textarea>
</form>

You don''t want to submit this form''s information, so you don''t need a form
element here.

</center>
</body>
</html>

As for your question, you can achieve optional client-side operation with

<form action="..." onsubmit="return handleSubmit(this)">
<script type="text/javascript">
function handleSubmit()
{
...

// if successful
return false;
}
</script>
</form>

But I strongly suggest you learn HTML first.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann


As for your question, you can achieve optional client-side operation with

>
<form action="..." onsubmit="return handleSubmit(this)">
<script type="text/javascript">
function handleSubmit()
{
...

// if successful
return false;
}
</script>
</form>

But I strongly suggest you learn HTML first.

ty i know its not vaied html but i just threw it up quickly to learn
to handle this type of interaction.

where should the script be inserted?
id i do this, but want the script to write into the textarea instead,
how do i do that?
<html>

<script type="text/javascript">
function myfunction()
{
alert("HELLO");
}
</script>

<body>
<center>

<h1><p style="font-family:times new roman;color:orange">
<b>Robber''s language encrypter/decrypter!</b>
</p></h1>

<p>
<select name="encdec">
<option value="encrypt">encrypt</option>
<option value="decrypt">decrypt</option>
</select>
</p>

<textarea name="enc" rows="10" cols="50">
</textarea>
s
<form>
<input type="button"
onclick="myfunction()"
value="submit">
</form>

</center>
</body>
</html>


globalrev wrote:

>As for your question, you can achieve optional client-side operation with

<form action="..." onsubmit="return handleSubmit(this)">
<script type="text/javascript">
function handleSubmit()
{
...

// if successful
return false;
}
</script>
</form>

But I strongly suggest you learn HTML first.


ty i know its not vaied html but i just threw it up quickly to learn
to handle this type of interaction.

You cannot expect invalid content to work; especially you cannot expect DOM
scripting to work within and on invalid markup.

http://diveintomark.org/archives/200..._wont_help_you

where should the script be inserted?

I wrote that already.

id i do this, but want the script to write into the textarea instead,
how do i do that?

Please read <http://jibbering.com/faq/>. All of it, especially the
introductory sections and the material referenced there.

<html>

<script type="text/javascript">
function myfunction()
{
alert("HELLO");
}
</script>

It is still not Valid. The DOCTYPE declaration is missing, and while
the start and end tags for the `head'' element are optional in HTML 4.01
Transitional, the `title'' element within the `head'' element is not.

http://validator.w3.org/

<body>
<center>

It is still deprecated (and is invalid with HTML 4.01 Strict).

<h1><p style="font-family:times new roman;color:orange">

The last item of a comma-separated `font-family'' value should be a generic
font family (here: `serif'') --

http://www.w3.org/TR/CSS2/fonts.html...ef-font-family
PointedEars
--
Anyone who slaps a ''this page is best viewed with Browser X'' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee


这篇关于将javascrpt插入textarea?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆