login  Naam:   Wachtwoord: 
Registreer je!
 Forum

Leeg of geen object

Offline Frederic - 26/05/2005 21:23 (laatste wijziging 26/05/2005 21:48)
Avatar van FredericPHP ver gevorderde Ik heb volgend script proberen 'na te bouwen':

http://javascri...ooser.html

Nu heb ik dit dus:
  1. <SCRIPT LANGUAGE="JavaScript">
  2. <!-- Original: Anand Raman (anand_raman@poboxes.com) -->
  3. <!-- Web Site: http://www.angelfire.com/ar/diduknow -->
  4.  
  5. <!-- This script and many more are available free online at -->
  6. <!-- The JavaScript Source!! http://javascript.internet.com -->
  7.  
  8. <!-- Begin
  9. function SelObj(formname,selname,textname,str) {
  10. this.formname = formname;
  11. this.selname = selname;
  12. this.textname = textname;
  13. this.select_str = str || '';
  14. this.selectArr = new Array();
  15. this.initialize = initialize;
  16. this.bldInitial = bldInitial;
  17. this.bldUpdate = bldUpdate;
  18. }
  19.  
  20. function initialize() {
  21. if (this.select_str =='') {
  22. for(var i=0;i<document.forms[this.formname][this.selname].options.length;i++) {
  23. this.selectArr[i] = document.forms[this.formname][this.selname].options[i];
  24. this.select_str += document.forms[this.formname][this.selname].options[i].value+":"+
  25. document.forms[this.formname][this.selname].options[i].text+",";
  26. }
  27. }
  28. else {
  29. var tempArr = this.select_str.split(',');
  30. for(var i=0;i<tempArr.length;i++) {
  31. var prop = tempArr[i].split(':');
  32. this.selectArr[i] = new Option(prop[1],prop[0]);
  33. }
  34. }
  35. return;
  36. }
  37. function bldInitial() {
  38. this.initialize();
  39. for(var i=0;i<this.selectArr.length;i++)
  40. document.forms[this.formname][this.selname].options[i] = this.selectArr[i];
  41. document.forms[this.formname][this.selname].options.length = this.selectArr.length;
  42. return;
  43. }
  44.  
  45. function bldUpdate() {
  46. var str = document.forms[this.formname][this.textname].value.replace('^\\s*','');
  47. if(str == '') {this.bldInitial();return;}
  48. this.initialize();
  49. var j = 0;
  50. pattern1 = new RegExp("^"+str,"i");
  51. for(var i=0;i<this.selectArr.length;i++)
  52. if(pattern1.test(this.selectArr[i].text))
  53. document.forms[this.formname][this.selname].options[j++] = this.selectArr[i];
  54. document.forms[this.formname][this.selname].options.length = j;
  55. if(j==1){
  56. document.forms[this.formname][this.selname].options[0].selected = true;
  57. //document.forms[this.formname][this.textname].value = document.forms[this.formname][this.selname].options[0].text;
  58. }
  59. }
  60. function setUp() {
  61. obj1 = new SelObj('nieuw_bericht','ontvanger','ontvanger_box');
  62. // menuform is the name of the form you use
  63. // itemlist is the name of the select pulldown menu you use
  64. // entry is the name of text box you use for typing in
  65. obj1.bldInitial();
  66. }
  67. // End -->
  68. </script>
  69. <script language="javascript" type="text/javascript">
  70. setUp();
  71. </script>
  72. <form name="nieuw_bericht">
  73. <table style="width: 50%;">
  74.  
  75. <tr style="background-color: #DEE2E7">
  76. <td width="25%">&nbsp;&raquo;&nbsp;Ontvanger:</td>
  77. <td width="75%">
  78. <font face="arial, helvetica" size="-1">Please enter the first few letters of the item you are looking for.</font>
  79. <br><br>
  80. <input type="text" name="ontvanger_box" size="30" onKeyUp="javascript:obj1.bldUpdate();">
  81. <select name="ontvanger">
  82. <option value="">-Selecteer de ontvanger-</option>
  83. <option value="203" style="color: #0000CC">AAAA</option>
  84.  
  85. <option value="3">lid0</option>
  86. <option value="103">lid0</option>
  87. <option value="4">lid1</option>
  88. <option value="104">lid1</option>
  89. <option value="13">lid10</option>
  90. <option value="113">lid10</option>
  91. <option value="57">lid54</option>
  92. </select> </td>
  93. </tr>
  94. </table>
  95. <input type="submit" name="Submit" value="Verzenden" />
  96. </form>


Maar dan krijg ik een error 'document.forum[...] is leeg of geen object'...
Het werkt ook niet..
Kan iemand me helpen?

2 antwoorden

Gesponsorde links
Offline Stijn - 26/05/2005 22:24
Avatar van Stijn PHP expert Misschien moet je en actie verwijzen in je form-tag:
<form action="pagina.php">

Zou het anders niet weten 
Offline Futs - 26/05/2005 23:15
Avatar van Futs Nieuw lid Heel logisch lijkt mij!

Want waar komt document.forum... vandaan? welk element heeft de naam forum?
Kijk eens naar je huidige object nieuw_bericht??
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.223s