Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > insert javascrpt into textarea?

Reply
Thread Tools

insert javascrpt into textarea?

 
 
globalrev
Guest
Posts: n/a
 
      05-11-2008
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>
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      05-11-2008
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
 
Reply With Quote
 
 
 
 
globalrev
Guest
Posts: n/a
 
      05-11-2008
> 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;colorrange">
<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>
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      05-11-2008
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;colorrange">


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
 
Reply With Quote
 
globalrev
Guest
Posts: n/a
 
      05-11-2008
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>
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      05-11-2008
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
 
Reply With Quote
 
globalrev
Guest
Posts: n/a
 
      05-11-2008
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>
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      05-11-2008
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
 
Reply With Quote
 
globalrev
Guest
Posts: n/a
 
      05-12-2008
On 12 Maj, 01:50, Thomas 'PointedEars' Lahn <(E-Mail Removed)>
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.
 
Reply With Quote
 
globalrev
Guest
Posts: n/a
 
      05-12-2008
<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...
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascrpt and User Controls. Help! =?Utf-8?B?ZXJpYw==?= ASP .Net 6 11-09-2007 02:04 PM
How to run a javascrpt function from the server? Rob Meade ASP .Net 7 03-18-2007 09:13 AM
javascrpt IDE Grzegorz Ślusarek Javascript 3 05-20-2006 02:29 PM
How To Insert Code With Javascript, How to insert into a div an amountof code Sergio del Amo Javascript 4 05-29-2005 02:45 AM
Where is "official", not Microsoft, spec for javascrpt, etc.? Howard Kaikow Javascript 4 10-12-2004 10:47 AM



Advertisments