Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> wstawienie tekstu do textarea po wciśnięci buttona, do wykorzystania np. w bbcode
zlw
post
Post #1





Grupa: Zarejestrowani
Postów: 44
Pomógł: 0
Dołączył: 30.04.2007
Skąd: WWA

Ostrzeżenie: (0%)
-----


Witam,

Tak jak w temacie.
Chciałem prosić o jakiś najprostszy skrypt, który wstawiałby dany tekst (np. [ b ] i po ponownym naciśnięciu [/ b ]) do textarea.

Ten post edytował zlw 6.10.2007, 15:03:52


--------------------
Krzysztof Zalewski :: blog

----------------------------------------------------------------------------------------

Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
Cysiaczek
post
Post #2





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Więc nie to forum...

Przenoszę na Szukam


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
skowron-line
post
Post #3





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

Ostrzeżenie: (0%)
-----


  1. <script type="text/javascript">
  2. function wstaw(insert){
  3. var textareaa = document.getElementById('text');
  4. textareaa.value = insert;
  5. var buttonn = document.getElementById('but');
  6. if(buttonn.value == ''){
  7. buttonn.value = ''];
  8. }else if(buttonn.value == '[/b]'){
  9. buttonn.value = '[b]';
  10. }
  11. }
  12. <input type="button" id="but" value="[b]" onclick="wstaw(this.value);">
  13. <textarea id="text"></textarea>
pisane z palca

Ten post edytował skowron-line 6.10.2007, 18:31:39


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
Go to the top of the page
+Quote Post
Nattfarinn
post
Post #4





Grupa: Zarejestrowani
Postów: 136
Pomógł: 22
Dołączył: 19.09.2007
Skąd: Sosnowiec

Ostrzeżenie: (0%)
-----


Jeśli chodzi o ekstremalnie prosty (i nie bez wad) przykład, to może nakieruje Cię coś takiego:

  1. var OpenedTags = new Array();
  2.  
  3. function BBCodeTag(field, open, close)
  4. {
  5. var TextField = document.getElementById(field);
  6. OpenedTags[open] = !OpenedTags[open];
  7. if(OpenedTags[open] != true) TextField.innerHTML = TextField.innerHTML + close;
  8. else TextField.innerHTML = TextField.innerHTML + open;
  9. }
  10.  
  11. <input type="button" onclick="BBCodeTag('pole_tekstowe', '', '')" value="B"><br>
  12. <textarea id="pole_tekstowe"></textarea>


Pozdrawiam


--------------------
Code should run as fast as necessary, but no faster; something important is always traded away to increase speed.
-- R. Pattis
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 00:26