/    Sign up×
Community /Pin to ProfileBookmark

input in textarea display in text box …

Hello, I was wondering if anyone knew how to type a character in a textarea and have its value displayed in the textarea and also in a text box (both on the same page)?

Any help would be appreciated . . . thanks.

Code One

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryMay 17.2003 — Something like this?
[CODE]
<input type="text" id="textbox">
<textarea id="textarea" onkeypress="CopyChar(event);"></textarea>
<script type="text/javascript">
function CopyChar(event){
if (event.which){
keyChar = String.fromCharCode(event.which);
} else {
keyChar = String.fromCharCode(event.keyCode);
}

document.getElementById('textbox').value = document.getElementById('textarea').value + keyChar;
}
</script>
[/CODE]


Adam
Copy linkTweet thisAlerts:
@Code_OneauthorMay 18.2003 — Exactly like this!

Good Job,

Code One

[b]edit:[/b] Well not exactly. I just got threw messing with this code for about 2 hours trying to minipulate it to work as I need it to but I am rather new to Jscript and I have to admit my powers are limited, though according to my post this code would be exactly what I needed. Anyway . . .

What I need is for when the user presses a button lets say the (A) button on the users keyboard the output inside the textarea would be the number 10. Now I have a text box [on the same page] and I would like onKeyup the letter (A) to be outputed in the textbox minus the value which is set to be the number 10 vs. the actual value of the pressed button which is the letter (A).

I hope you understand and can help all is much appreciated,

Code One

P.s. 10 points to anyone who can decipher my quote.
Copy linkTweet thisAlerts:
@AdamGundryMay 18.2003 — I'm afraid I don't quite understand. Do you mean that when the user types a letter the ASCII value minus 10 should be outputted? Is the number 10 constant, or dependant on the letter? Can you explain a little more clearly, please.

Adam

P.S. Revolutionary
Copy linkTweet thisAlerts:
@CharlesMay 18.2003 — [font=monospace]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="Content-Script-Type" content="text/javascript">

<script type="text/javascript">

<!--

String.code = {a:26, b:25, c:24, d:23, e:22, f:21, g:20, h:19, i:18, j:17, k:16, l:15, m:14, n:13, o:12, p:11, q:10, r:9, s:8, t:7, u:6, v:5, w:4, x:3, y:2, z:1}

String.prototype.toCode = function () {

var a = this.split('');

for (j=0; j<a.length; j++) {if (String.code[a[j]]) a[j] = String.code[a[j]]}

return a.join('');

}

// -->

</script>

<form action="">

<div>

<p><label>Characters<br>

<textarea name="chars" rows="5" cols="20" onkeyup="this.form.codes.value = this.value.toCode()"></textarea></label></p>

<p><label>Codes<br>

<textarea name="codes" rows="5" cols="20" readonly></textarea></label></p>

</div>

</form>[/font]
Copy linkTweet thisAlerts:
@Code_OneauthorMay 18.2003 — please observe the work of a genius above for my question threw him has been answered!!!

Great Job, nice pic!

Code One

P.s. 10 points goes to Adam for the deciphering my qoute!!

?
×

Success!

Help @Code_One spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...