Witam mam taki kłopot mam 2 selecty ( co = lista tagów , gdzie = lista tagów - ktore sa przeniesione z 1 po klikniecu ) i mam pole input gdzie podaje nazwe taga i on mi sie automatycznie doda to selecta o id gdzie i teraz pytanie. jak zrobic: jezeli tag kktory chce dodac wystepuje w 1 select (id=co) to nic sie nie dzieje.

taki kod zrobiłem:

  1. <script type="text/javascript">
  2. function dodaj()
  3. {
  4. // z to do from
  5. // usuwamy z from
  6. var x=document.getElementById('co');
  7. var y=document.getElementById('gdzie');
  8. y.options[y.length] = new Option(x.options[x.selectedIndex].text,x.options[x.selectedIndex].value);
  9. x.remove(x.selectedIndex);
  10.  
  11. for (i=0;i<=100;i++)
  12. {
  13. y.options[y.length-1].selected = true;
  14. }
  15. }
  16.  
  17. function usun()
  18. {
  19. var x=document.getElementById('gdzie');
  20. var y=document.getElementById('co');
  21. y.options[y.length] = new Option(x.options[x.selectedIndex].text,x.options[x.selectedIndex].value);
  22.  
  23.  
  24. x.remove(x.selectedIndex);
  25.  
  26. for (i=0;i<=x.length;i++)
  27. {
  28. x.options[i].selected = true;
  29. }
  30.  
  31. }
  32.  
  33.  
  34. function dodajTag()
  35. {
  36. // z to do from
  37. // usuwamy z from
  38. var x=document.getElementById('newtag');
  39. var y=document.getElementById('gdzie');
  40. var z=document.getElementById('co');
  41. y.options[y.length] = new Option(x.value,x.value);
  42.  
  43. // zapis do bazy
  44. ad = 'addtags.php?FOR=';
  45. ajaxpage(ad+x.value,'div_add_tag','utf-8')
  46. // zaznacz wszystko
  47. for (i=0;i<=100;i++)
  48. {
  49. y.options[y.length-1].selected = true;
  50. }
  51.  
  52. // liczymy
  53. for (i=0;i<=z.length;i++)
  54. {
  55. if (z.options[i]==x.value)
  56. {
  57. alert("Tag wystepuje");
  58. }
  59. }
  60.  
  61.  
  62.  
  63. }
  64.  
  65.  


ma ktos jakis pomysł nie chce korzystac z innych framwerkow js wiec advajax itp nie wchodzą w gre.