Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ajax] Kliknięcie buttona i zapis wartości do zmiennej
brutal1985
post 29.03.2012, 18:21:28
Post #1





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 27.08.2011

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


Witam.
Mam na stronie skrypt, który służy do wstawiania tagów BBCode do pola tekstowego i późniejszego zapisu go wraz z pozostałym tekstem do bazy danych.
Oto jego kod.
  1. function addText(Text, Message)
  2. {
  3. var obj = document.form.krotka_tresc;
  4. obj.focus();
  5. if (document.selection && document.selection.createRange) // Internet Explorer
  6. {
  7. sel = document.selection.createRange();
  8. if (sel.parentElement() == obj) sel.text = Text;
  9. }
  10. else if (typeof(obj) != "undefined") // Firefox
  11. {
  12. var longueur = parseInt(obj.value.length);
  13. var selStart = obj.selectionStart;
  14. var selEnd = obj.selectionEnd;
  15. obj.value = obj.value.substring(0, selStart) + Text + obj.value.substring(selEnd, longueur);
  16. }
  17. else obj.value += Text;
  18. obj.focus();
  19. }
  20. function addTags(Tag, fTag, Message)
  21. {
  22. var obj = document.form.krotka_tresc;
  23. obj.focus();
  24. if (document.selection && document.selection.createRange) // Internet Explorer
  25. {
  26. sel = document.selection.createRange();
  27. if (sel.parentElement() == obj) sel.text = Tag + sel.text + fTag;
  28. }
  29. else if (typeof(obj) != "undefined") // Firefox
  30. {
  31. var longueur = parseInt(obj.value.length);
  32. var selStart = obj.selectionStart;
  33. var selEnd = obj.selectionEnd;
  34. obj.value = obj.value.substring(0, selStart) + Tag + obj.value.substring(selStart, selEnd) + fTag + obj.value.substring(selEnd, longueur);
  35. }
  36. else obj.value += Tag + fTag;
  37. obj.focus();
  38. }


Moje pytanie jest następujące:
Czy da się przerobić ten skrypt w taki sposób, aby wartości wciśniętych buttonów nie były zapisywane w polu tekstowym, ale w zmiennej, a najlepiej w sesji?
Go to the top of the page
+Quote Post

Posty w temacie


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 Wersja Lo-Fi Aktualny czas: 18.07.2025 - 01:56