login  Naam:   Wachtwoord: 
Registreer je!
 Forum

javascript keuzemenu kan niet onthouden

Offline Gust - 09/06/2009 10:52
Avatar van GustMySQL interesse Zie deze pagina

Als je in het bovenste veld iets invult, verschijnt dat ook bij de rest. Als je dan op "other" klikt in het menu, kun je ernaast iets anders invullen.

Dat wordt allemaal mooi naar de database gestuurd. Maar als ik dit wil updaten, dan zie ik alles zoals het was nog voordat je het kunt invullen. Het javascript begint gewoon opnieuw en onthoudt niet wat je eerst gekozen hebt. zeer vervelend als je iets wilt verbeteren.

Valt hier iets aan te doen?

  1. <script type="text/javascript">
  2. function verander(arr) {
  3. applyToSelect(document.getElementById('select_citycenter'),arr);
  4. applyToSelect(document.getElementById('select_exhibitioncentre'),arr);
  5. applyToSelect(document.getElementById('select_trainstation'),arr);
  6. applyToSelect(document.getElementById('select_busstation'),arr);
  7. applyToSelect(document.getElementById('select_airplane1'),arr);
  8. applyToSelect(document.getElementById('select_airplane2'),arr);
  9. applyToSelect(document.getElementById('select_airplane3'),arr);
  10. applyToSelect(document.getElementById('select_airplane4'),arr);
  11. applyToSelect(document.getElementById('select_taxi'),arr);
  12. applyToSelect(document.getElementById('select_bustram'),arr);
  13. applyToSelect(document.getElementById('select_metro'),arr);
  14. applyToSelect(document.getElementById('select_garage'),arr);
  15. applyToSelect(document.getElementById('select_highway'),arr);
  16. applyToSelect(document.getElementById('select_sport'),arr);
  17. applyToSelect(document.getElementById('select_hospital'),arr);
  18. applyToSelect(document.getElementById('select_wellness'),arr);
  19. applyToSelect(document.getElementById('select_pool'),arr);
  20. applyToSelect(document.getElementById('select_tennis'),arr);
  21. applyToSelect(document.getElementById('select_golf9h'),arr);
  22. applyToSelect(document.getElementById('select_golf18h'),arr);
  23. applyToSelect(document.getElementById('select_bike'),arr);
  24. applyToSelect(document.getElementById('select_car'),arr);
  25. applyToSelect(document.getElementById('select_shoppingvillage'),arr);
  26. applyToSelect(document.getElementById('select_shoppingarea'),arr);
  27. applyToSelect(document.getElementById('select_fitness'),arr);
  28. applyToSelect(document.getElementById('select_bigcity'),arr);
  29.  
  30. }
  31.  
  32. function applyToSelect(el, arr)
  33. {
  34. el.options.length = 0;
  35. for(var i = 0; i< arr.length; i++ )
  36. {
  37. el.options[el.options.length] = new Option(arr[i], arr[i]);
  38. el.options[el.options.length] = new Option("Other");
  39. }
  40. el.onchange = new Function("selectChanged(this);");
  41. }
  42.  
  43. function selectChanged(el)
  44. {
  45. if(el.id == "select_citycenter")
  46. el2 = document.getElementById("citycenter");
  47. if(el.id == "select_exhibitioncentre")
  48. el2 = document.getElementById("exhibitioncentre");
  49. if(el.id == "select_trainstation")
  50. el2 = document.getElementById("trainstation");
  51. if(el.id == "select_busstation")
  52. el2 = document.getElementById("busstation");
  53. if(el.id == "select_airplane1")
  54. el2 = document.getElementById("airplane1");
  55. if(el.id == "select_airplane2")
  56. el2 = document.getElementById("airplane2");
  57. if(el.id == "select_airplane3")
  58. el2 = document.getElementById("airplane3");
  59. if(el.id == "select_airplane4")
  60. el2 = document.getElementById("airplane4");
  61. if(el.id == "select_taxi")
  62. el2 = document.getElementById("taxi");
  63. if(el.id == "select_bustram")
  64. el2 = document.getElementById("bustram");
  65. if(el.id == "select_metro")
  66. el2 = document.getElementById("metro");
  67. if(el.id == "select_garage")
  68. el2 = document.getElementById("garage");
  69. if(el.id == "select_highway")
  70. el2 = document.getElementById("highway");
  71. if(el.id == "select_sport")
  72. el2 = document.getElementById("sport");
  73. if(el.id == "select_hospital")
  74. el2 = document.getElementById("hospital");
  75. if(el.id == "select_wellness")
  76. el2 = document.getElementById("wellness");
  77. if(el.id == "select_pool")
  78. el2 = document.getElementById("pool");
  79. if(el.id == "select_tennis")
  80. el2 = document.getElementById("tennis");
  81. if(el.id == "select_golf9h")
  82. el2 = document.getElementById("golf9h");
  83. if(el.id == "select_golf18h")
  84. el2 = document.getElementById("golf18h");
  85. if(el.id == "select_bike")
  86. el2 = document.getElementById("bike");
  87. if(el.id == "select_car")
  88. el2 = document.getElementById("car");
  89. if(el.id == "select_shoppingvillage")
  90. el2 = document.getElementById("shoppingvillage");
  91. if(el.id == "select_shoppingarea")
  92. el2 = document.getElementById("shoppingarea");
  93. if(el.id == "select_fitness")
  94. el2 = document.getElementById("fitness");
  95. if(el.id == "select_bigcity")
  96. el2 = document.getElementById("bigcity");
  97.  
  98.  
  99. if(el.selectedIndex != el.options.length - 1)
  100. el2.readOnly = true;
  101. else
  102. {
  103. el2.readOnly = false;
  104. el2.focus();
  105. }
  106. }
  107. </script>
  108. <script type="text/javascript">
  109. function setThis() {
  110.  
  111. var aantal = 26;
  112. var wat = document.getElementById('watt').value;
  113.  
  114. if(wat != "kies"){
  115. for (i = 1; i <= aantal; i++){
  116. document.getElementById("wat_"+i).innerHTML = wat;
  117. }
  118. }
  119. }
  120. </script>

0 antwoorden

Gesponsorde links
Er zijn nog geen reacties op dit bericht.
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.208s