473,287 Members | 1,741 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,287 software developers and data experts.

insert javascrpt into textarea?

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>
Jun 27 '08 #1
15 1774
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
Jun 27 '08 #2
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>
Jun 27 '08 #3
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
Jun 27 '08 #4
ok now i think it is, is there a site that can validate a htmlpage run
on my own computer(not a server or webhotel)?

so now if it is ok, how do i insert text upon submit into the textarea
or in another textarea below the now visible one?
also, how can i center the textarea vertically?
<html>
<head>
<title>robber's language</title>
<style type="text/css">
<!--
body {
margin: 0px;
padding: 0px;
}
#header {
background: #FDD017;
width: 100%;
height: 10%;
font-size: xx-large;
text-align: center;
}
#content {
background: white;
float: right;
width: 100%;
height: 90%;
text-align: center;
}
a:link {color: black; }
a:visited {color: white; }
a:hover {color: black; }
a:active {color: black; }
-->
</style>
</head>
<body>
<script type="text/javascript">
function myfunction()
{
alert("HELLO");
}
</script>
<div id="header">
<b>Robber's language encrypter/decrypter</b>
</div>
<div id="content">
<textarea rows="10" cols="30">
</textarea>
<form>
<input type="button"
onclick="myfunction()"
value="submit">
</form>
</div>
</body>
</html>
Jun 27 '08 #5
globalrev wrote:
ok now i think it is,
Is *what*?
is there a site that can validate a htmlpage run
on my own computer(not a server or webhotel)?
http://validator.w3.org/#validate-by-upload
so now if it is ok, how do i insert text upon submit into the textarea
or in another textarea below the now visible one?
Read my posting again.
also, how can i center the textarea vertically?
The most compatible way is to use a table cell:

<td style="vertical-align: middle">...-</td>

Further layout questions should be asked in the
comp.infosystems.www.authoring.* subhierarchy.
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
Jun 27 '08 #6
just want to say i really appreciate your help. just find this
frustrating because its not really what i want to spend my time on,
want to spend it on my translator-program and just want a simple
working webapplication.
i guess also its fairly trivial once you know how to do it though.

now i have a valid strict html 4.01 document.

how do i take the text in the textarea when i press submit, then
transform the text and put it back in the window(or somehwere else).

the actual transformastion ill obv do by myself but how to take it and
send it back i need to know. there just is no clear example anywhere i
look on how to do this which is weird since it is standard procedure
on a lot of apps.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >

<title>robber's language</title>
<style type="text/css">
<!--
body {
margin: 0px;
padding: 0px;
}
#header {
background: #FDD017;
width: 100%;
height: 10%;
font-size: xx-large;
text-align: center;
}
#content {
background: white;
float: right;
width: 100%;
height: 90%;
text-align: center;
}
a:link {color: black; }
a:visited {color: white; }
a:hover {color: black; }
a:active {color: black; }
-->
</style>
</head>
<body>

<div id="header">
<b>Robber's language encrypter/decrypter</b>
</div>
<div id="content">
<textarea name="enc" rows="10" cols="30">
</textarea>
</div>
</body>
</html>
Jun 27 '08 #7
Thomas 'PointedEars' Lahn wrote:
globalrev wrote:
>so now if it is ok, how do i insert text upon submit into the textarea
or in another textarea below the now visible one?

Read my posting again.
Especially my first followup. Obviously you will also need at least one
input control or a submit button within the `form' element, so that the form
can be submitted and its `submit' event created and handled by the
`onsubmit' attribute value.
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
Jun 27 '08 #8
On 12 Maj, 01:50, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
Thomas 'PointedEars' Lahn wrote:
globalrev wrote:
so now if it is ok, how do i insert text upon submit into the textarea
or in another textarea below the now visible one?
Read my posting again.

Especially my first followup. Obviously you will also need at least one
input control or a submit button within the `form' element, so that the form
can be submitted and its `submit' event created and handled by the
`onsubmit' attribute value.

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

and obv i dont get it since i have read that several times already.
Jun 27 '08 #9
<form action="..." onsubmit="return handleSubmit(this)">
<script type="text/javascript">
function handleSubmit()
{
...

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

should a textarea be place dinsid ehere? and a submitbutton? i dont
get it. seriously. call me stupid but...
Jun 27 '08 #10
globalrev wrote:
<form action="..." onsubmit="return handleSubmit(this)">
<script type="text/javascript">
function handleSubmit()
{
...

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

should a textarea be place dinsid ehere? and a submitbutton? i dont
get it. seriously. call me stupid but...
<form action="..." onsubmit="return handleSubmit(this)">
<script type="text/javascript">
function handleSubmit(f)
{
var es = f.elements;
var translation = translate(es['source'].value);
if (translation)
{
es['target'].value = translation;
}
else
{
// handle translation error
}

return false;
}
</script>
<div><textarea name="source" cols="80" rows="6"></textarea></div>
<div><input type="submit" value="Translate"></div>
<div><textarea name="target" cols="80" rows="6"></textarea></div>
</form>

Besides the fact that it must be within the `head' or `body' element, the
current location of the `script' element is really only my personal
preference: I like the script code to be near the form that it is operating on.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Jun 27 '08 #11
On 12 Maj, 04:02, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
globalrev wrote:
<form action="..." onsubmit="return handleSubmit(this)">
<script type="text/javascript">
function handleSubmit()
{
...
// if successful
return false;
}
</script>
</form>
should a textarea be place dinsid ehere? and a submitbutton? i dont
get it. seriously. call me stupid but...

<form action="..." onsubmit="return handleSubmit(this)">
<script type="text/javascript">
function handleSubmit(f)
{
var es = f.elements;
var translation = translate(es['source'].value);
if (translation)
{
es['target'].value = translation;
}
else
{
// handle translation error
}

return false;
}
</script>
<div><textarea name="source" cols="80" rows="6"></textarea></div>
<div><input type="submit" value="Translate"></div>
<div><textarea name="target" cols="80" rows="6"></textarea></div>
</form>

Besides the fact that it must be within the `head' or `body' element, the
current location of the `script' element is really only my personal
preference: I like the script code to be near the form that it is operating on.

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16


thanks but when i write something and press translate i get handed to
another site. it doesnt write into the second textarea.
i understand the code but dont see how to change it. tried Translate
to translate in case it is case sensitive and to put
es['target'].value = translation; in the else in case it was just
wrong boolean logic.

but it always redirects to new "not found".
Jun 27 '08 #12
[snipped attribution novel]

globalrev wrote:
Thomas 'PointedEars' Lahn wrote:
> <form action="..." onsubmit="return handleSubmit(this)">
<script type="text/javascript">
function handleSubmit(f)
{
var es = f.elements;
var translation = translate(es['source'].value);
if (translation)
{
es['target'].value = translation;
}
else
{
// handle translation error
}

return false;
}
</script>
<div><textarea name="source" cols="80" rows="6"></textarea></div>
<div><input type="submit" value="Translate"></div>
<div><textarea name="target" cols="80" rows="6"></textarea></div>
</form>

Besides the fact that it must be within the `head' or `body' element, the
current location of the `script' element is really only my personal
preference: I like the script code to be near the form that it is operating on.
[...]
Will you please stop full-quoting?
thanks but when i write something and press translate i get handed to
another site. it doesnt write into the second textarea.
That can only be because you have not copied the code as is and forgot
either the `return false' or the `return' before handleSubmit(...).
i understand the code [...]
No, you don't. I suggest you start learning for real. NOW.

BTW, the pronoun `I' as well as the first character of the first word of a
sentence is spelled with a capital letter. I think the latter applies to
Swedish too, doesn't it?
Score adjusted

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
Jun 27 '08 #13
You are the only one that writes with capitals on the internets ;).

Anyway I run the site from a python-app so thats why it redirected.

Launching the html-site by itself it doesnt redirect but it doesnt do
anything either.

Is it supposed to put anything I write in the toparea into the bottom
area?
Jun 27 '08 #14
i got it to work now. thanks for all your help.
<form action="..." onsubmit="return handleSubmit(this)">
<script type="text/javascript">
function handleSubmit(f)
{
f.elements['target'].value = f.elements['source'].value;
}
</script>
<div><textarea name="source" cols="60" rows="10"></textarea></div>
<div><input type="submit" value="translate"></div>
<div><textarea name="target" cols="60" rows="10"></textarea></div>
</form>
Jun 27 '08 #15
In comp.lang.javascript message <4eb861ff-00ac-44d5-b12d-5aec8a556a8e@p2
5g2000hsf.googlegroups.com>, Sun, 11 May 2008 15:04:16, globalrev
<sk*******@yahoo.seposted:
>ok now i think it is, is there a site that can validate a htmlpage run
on my own computer(not a server or webhotel)?
Download the free browser Opera, and Ctrl-Alt-V will submit the current
page to a W3 validator, over the net.

If you mean, however, that you want to validate your page without using
the Net at the time, then W3's TIDY can be used in check-only fashion.
Whether or not it is a full validator, it can certainly detect many
errors.

For more, see in my <URL:http://www.merlyn.demon.co.uk/www-use2.htm>; it
needs updating, but, as far as I can immediately see, it's satisfactory
as far as it goes.

<FAQENTRY>
Sec 2.3 needs something on the need for valid HTML.
Section 5 needs something about maintainers who have ceased maintaining.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE7 FF2 Op9 Sf3
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jun 27 '08 #16

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

Similar topics

2
by: Lloyd | last post by:
I am trying to insert text in a text area. I need to insert one set of values on the left side of the text area and have corresponding values on the left side of the text area in an even column....
8
by: =?Utf-8?B?QkxVRVNUQVI=?= | last post by:
HELLO, I AM A NEW BII TO ASP,AND I NEED HELP ON THIS ISSUE. I HAVE A .ASP FORM WHICH IS ALREADY BUILT WITH 5 QUESTIONS AND 5 TEXTAREAS RESPECTIVELY.THESE 5 QUESTIONS ARE NOT FIX,THERE WILL BE...
58
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.