Witam,
Oto kod formularza:
script.js
  1. function wstaw(start_tag,stop_tag){
  2. var okno = document.getElementById("content_input");
  3. if(!okno.setSelectionRange) {
  4. var selected = document.selection.createRange().text;
  5. if(selected.length <= 0) {
  6. okno.value +=start_tag + stop_tag;
  7. } else {
  8. document.selection.createRange().text = start_tag + selected + stop_tag;
  9. }
  10. } else {
  11. var pretext = okno.value.substring(0, okno.selectionStart);
  12. var codetext = start_tag + okno.value.substring(okno.selectionStart,
  13. okno.selectionEnd) + stop_tag;
  14. var posttext = okno.value.substring(okno.selectionEnd, okno.value.length)
  15. if(codetext == start_tag + stop_tag) {
  16. okno.value += start_tag + stop_tag;
  17. } else {
  18. okno.value = pretext + codetext + posttext;
  19. }
  20. }
  21. okno.focus ();
  22. }


formularz:

  1. <script src="script.js"></script>
  2. <form action="?" method="post">
  3.  
  4.  
  5. <?php
  6.  
  7. $result = mysql_query('SELECT * FROM armors WHERE type like "%ody" ORDER BY armor_id ')or die('Nie mogę połączyć się z bazą danych: '.mysql_error());
  8. while ($row = mysql_fetch_assoc($result))
  9. {
  10. $icon = unserialize($row['icon']);
  11. $stats = unserialize($row['stats']);
  12.  
  13.  
  14. ?>
  15. <input type="button" onclick="wstaw('<?php echo show_icona(unserialize($row['icon'])) ?>','a')">
  16.  
  17. <?php
  18. }
  19.  
  20. ?>
  21. <input type="button" value="u" onclick="wstaw('a','','')">
  22. <input type="button" value="s" onclick="wstaw('','')">
  23. <input type="button" value="link" onclick="wstaw('','')">
  24. <input type="button" value="obrazek" onclick="wstaw('')">
  25. <input type="button" value="cytat" onclick="wstaw('<!--quoteo--><div class='quotetop'>Cytat</div><div class='quotemain'><!--quotec-->','<!--QuoteEnd--></div><!--QuoteEEnd-->')">
  26. <input type="button" value="kod" onclick="wstaw('<!--c1--><div class='codetop'>Kod</div><div class='codemain'><!--ec1-->','<!--c2--></div><!--ec2-->')">
  27. </div>
  28. <label>Treść</label>
  29. <textarea id="content_input" name="content"></textarea>
  30. <br/>
  31. <input type="submit" name="submit" value="Wyślij">
  32. </form>


Jak widac w tym inpucie: <input type="button" onclick="wstaw('<?php echo show_icona(unserialize($row['icon'])) ?>','a')">

Mam funkcję zaincludowaną z innego pliku, w pętli. Chciałbym, aby po kliknięciu w button do formularza wskakiwał kod tej funkcji. Niestety całość nie działa, gdyż jest parsowana i kod nie jest wyświetlany w postaci tekstu. Jak to naprawić?
Zawartość funkcji w inpucie:
  1. function show_icon($icon)
  2. {
  3. return '<div class="icon" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; background-attachment: scroll; background-size: auto; background-origin: padding-box; background-clip: border-box; background-color: transparent; width: '.$icon['graphic']['size']['x'].'px; height: '.$icon['graphic']['size']['y'].'px; display: block; overflow-x: hidden; overflow-y: hidden; background-image: url(http://mf3.pl/static/'.$icon['graphic']['src'].'); background-repeat: no-repeat; background-position: -'.($icon['graphic']['size']['x'] * $icon['source']['x']).'px -'.($icon['graphic']['size']['y'] * $icon['source']['y']).'px">';
  4. }