🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.javascript
Article #39464

Re: Zmiana wyświetlania " w locie"

#39464
From: porneL
Date: Sat, 15 Apr 2006 20:16
54 lines
2610 bytes
On Sat, 15 Apr 2006 20:47:32 +0100, Jarosław Ziółkowski  
<ziolkowski_jaroslaw@o2.pl> wrote:


>>> Chciałbym żeby po wpisaniu innej wartości bez przeładowywania strony   
>>> wyświetlana była jej wartość. Docelowo chcę żeby wyświetlane było  
>>> tyle  inputów ile wpisano w polu ile. No ale kombinuję narazie tylko  
>>> z  wyświetlaniem zawartości później mam nadzieję, że sobie poradzę.
>>   Nie używaj document.write, najlepiej w ogóle. Pogooglaj o W3C DOM   
>> (createElement, createTextNode, append/removeChild) albo innerHTML.
>>
> Więc z tym focus kombinuje dobrze żeby się to w locie zmieniało?
>
> Poczytałem trochę ale chyba jednak czegoś nie rozumiem.
>
> Napisałem
>
> function check(){
>    input = document.createElement('input');
>   input.setAttribute('type', 'text');
>   input.setAttribute('name', 'ddd');
>   input.setAttribute('id', 'ddd');
>   input.setAttribute('class', 'input_text');
>   input.setAttribute('style', 'width: 200px;');
> ddd.appendChild(input);
> }
> check();

musisz skądś wziąc element "ddd". Tutaj tworzysz input o takim ID i  
dodajesz do... niewiadomo czego.

BTW: input.setAttribute('class', 'input_text'); => input.className =  
'input_text';
    input.setAttribute('style', 'width: 200px;'); => input.style.width =  
'200px';
(a i tak oba lepiej wywalić do arkusza)

Do wyświetlania:

<span id="output"></span>

var o = document.getElementById('output');
if (o.firstChild) o.removeChild(o.firstChild);
o.appendChild(document.createTextNode(tekst));

albo mniej elegancko, ale prosciej:

o.innerHTML = tekst;


(pisane z palca, mogą być drobne błędy)
-- 
* html {redirect-to: url(http://kurs.browsehappy.pl);}
this.author = new Geek("porneL");
Technical Details
Message-ID: <op.s72fxzz7fux2e6@pornel.net>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail
References: <e1re97$hpl$1@inews.gazeta.pl> <op.s72ck6lofux2e6@pornel.net> <e1rikl$4m6$1@inews.gazeta.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail
From: porneL <niusy@pornel.net>
Newsgroups: pl.comp.lang.javascript
Subject: Re: Zmiana wyświetlania " w locie"
Date: Sat, 15 Apr 2006 21:16:37 +0100
Organization: "Portal Gazeta.pl -> http://www.gazeta.pl"
Lines: 54
Message-ID: <op.s72fxzz7fux2e6@pornel.net>
References: <e1re97$hpl$1@inews.gazeta.pl> <op.s72ck6lofux2e6@pornel.net> <e1rikl$4m6$1@inews.gazeta.pl>
NNTP-Posting-Host: pornel.plus.com
Mime-Version: 1.0
X-Trace: inews.gazeta.pl 1145132198 12185 84.92.248.233 (15 Apr 2006 20:16:38 GMT)
X-Complaints-To: usenet@agora.pl
NNTP-Posting-Date: Sat, 15 Apr 2006 20:16:38 +0000 (UTC)
X-User: pornelspam
User-Agent: Opera Mail(BETA2)/9.00 (MacPPC)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit