Article View: pl.comp.lang.javascript
Article #49526Wypełnianie i czyszczenie teaxarea
From: mosh
Date: Sat, 21 Nov 2009 11:59
Date: Sat, 21 Nov 2009 11:59
62 lines
2165 bytes
2165 bytes
Witam
Od razu zaznaczam, że jestem gorzej niż lama z JS ;)
Chciałbym napisać skrypt w JS, po zdarzeniu onclick
wypełnia mi textarea jakimś tekstem, po kolejnym kliknięciu
kasuje jego zawartość i wypełnia innym tekstem (zastępuje bieżący innym)
naskrobałem takie coś:
JS:
function wypelnij_TA(x) {
var org = new Array();
org[6] = 'oryginal txt';
var tra = new Array();
tra[6] = 'translated txt';
// ponizsze powinno czyscic TA
//document.translator.TA_org.value='';
//document.translator.TA_tra.value='';
//wyplenianie TA
htmlData(org[x], 'TA_org');
htmlData(tra[x], 'TA_tra');
}
function htmlData(selectValue,targetTextArea)
{
var txtNode=document.createTextNode(selectValue);
var textArea=document.getElementById(targetTextArea);
textArea.appendChild(txtNode);
}
HTML:
<span onclick="wypelnij_TA('6');">wypełnij TA</span>
<form name="translator" id="translator" method="post" action="#">
<textarea name="TA_org" id="TA_org" disabled="disabled"
cols="40"></textarea>
<textarea name="TA_tra" id="TA_tra" cols="40"></textarea>
</form>
wypełnianie TextArea działa, ale każde onclick dodaje kolejny text do
zawartości.
Więc przed wypełnieniem dodaje:
document.translator.TA_org.value='';
ale wtedy textarea w ogóle się nie wypełnia :/
Jakiś pomysł jak to rozwiązać ?
będę wdzięczny za pomoc :D
pozdro, mosh
Technical Details
Message-ID:
<he8o7p$3nd$1@inews.gazeta.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail From: mosh <mosh@webfly.pl> Newsgroups: pl.comp.lang.javascript Subject: Wypełnianie i czyszczenie teaxarea Date: Sat, 21 Nov 2009 12:59:32 +0100 Organization: "Portal Gazeta.pl -> http://www.gazeta.pl" Lines: 62 Message-ID: <he8o7p$3nd$1@inews.gazeta.pl> NNTP-Posting-Host: 188.33.214.238 Mime-Version: 1.0 X-Trace: inews.gazeta.pl 1258808380 3821 188.33.214.238 (21 Nov 2009 12:59:40 GMT) X-Complaints-To: usenet@agora.pl NNTP-Posting-Date: Sat, 21 Nov 2009 12:59:40 +0000 (UTC) X-User: bigmosh User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit