login  Naam:   Wachtwoord: 
Registreer je!
 Forum

script blijft [object] weergeven

Offline prorsoft - 11/06/2005 15:36
Avatar van prorsoftPHP gevorderde hallo,
ik heb een script gemaakt voor een treeview die de gegevens uit een SF database haalt:
  1. <html>
  2. <head>
  3. <?php
  4. function sp($str)
  5. {
  6. global $key;
  7. $ret=str_replace(" ","_",$str);
  8. return $ret.$key;
  9. }
  10. ?>
  11. <style>
  12. div.domainlist {color: #000099; font-family: Arial,Helvetica; font-size: 12; margin-left: 10px; background-color: #ffffce;}
  13. div#seldomain {color: #000099; font-family: Arial,Helvetica; font-size: 12; margin-left: 10px; background-color: #ffffce; position: absolute; left: 5px; top: 5px;}
  14. </style>
  15. <script type="text/javascript">
  16. var setone=false;
  17. var current="";
  18. var cwrd="";
  19. function insdom(target,twrd,tdesc)
  20. {
  21. if(setone)
  22. current.style.backgroundColor="";
  23. else
  24. setone=true;
  25. if(target==current)
  26. {
  27. current.style.backgroundColor="";
  28. setone=false;
  29. current="";
  30. cwrd="";
  31. }
  32. else
  33. {
  34. target.style.backgroundColor="#FF4444";
  35. current=target;
  36. cwrd=twrd;
  37. }
  38. parent.scripture.location.href="descdom.php?title="+twrd+"&desc="+tdesc;
  39. if(!setone)
  40. seldomain.innerHTML="You haven't selected a domain. Click a domain to select it.";
  41. else
  42. {
  43. seldomain.innerHTML="You've selected the domain "+cwrd+". <input type=\"button\" onClick=\"insert('"+cwrd+"');\" value=\"Insert\" />";
  44. seldomain.innerHTML+="<input type=\"button\" onClick=\"clearfield();\" value=\"Clear\" />";
  45. }
  46. }
  47. function insert(theword)
  48. {
  49. if(parent.navbar.entrysearch.selectlexical.value=="")
  50. parent.navbar.entrysearch.selectlexical.value=theword;
  51. else
  52. parent.navbar.entrysearch.selectlexical.value+="; "+theword;
  53. }
  54. function clearfield()
  55. {
  56. parent.navbar.entrysearch.selectlexical.value="";
  57. }
  58. function toggledom( target, targetIdImg ){
  59. if (target.style.display == "none"){
  60. target.style.display = "block";
  61. targetIdImg.src="minus.png";
  62. } else {
  63. target.style.display = "none";
  64. targetIdImg.src="plus.png";
  65. }
  66. }
  67. function clicktoggle(target,twrd,tdiv,tdesc)
  68. {
  69. if(setone)
  70. current.style.backgroundColor="";
  71. else
  72. setone=true;
  73. if(target==current)
  74. {
  75. current.style.backgroundColor="";
  76. setone=false;
  77. current="";
  78. cwrd="";
  79. }
  80. else
  81. {
  82. target.style.backgroundColor="#FF4444";
  83. current=target;
  84. cwrd=twrd;
  85. }
  86. parent.scripture.location.href="descdom.php?title="+twrd+"&desc="+tdesc;
  87. if(!setone)
  88. seldomain.innerHTML="You haven't selected a domain. Click a domain to select it.";
  89. else
  90. {
  91. seldomain.innerHTML="You've selected the domain "+cwrd+". <input type=\"button\" onClick=\"insert('"+cwrd+"');\" value=\"Insert\" />";
  92. seldomain.innerHTML+="<input type=\"button\" onClick=\"clearfield();\" value=\"Clear\" />";
  93. }
  94. if (tdiv.style.display == "none"){
  95. tdiv.style.display = "block";
  96. tdivImg.src="minus.png";
  97. } else {
  98. tdiv.style.display = "none";
  99. tdivImg.src="plus.png";
  100. }
  101. }
  102. </script>
  103. </head>
  104. <body bgcolor="#ffffce">
  105. <div id="seldomain">You haven't selected a domain. Click a domain to select it.<input type="button" onClick="clearfield();" value="Clear" /></div>
  106. <br />
  107. <div class="domainlist">
  108. <?php
  109. $confile=file("sdbh-u/sdbh-u.tv1") or die("\nFailed reading the database.\n");
  110. $curniv=1;
  111. foreach($confile as $key=>$value)
  112. {
  113. $temparr=explode("\$",$value);
  114. $niv=substr($temparr[0],-1);
  115. $name=$temparr[1];
  116. $desc=htmlentities($temparr[2]);
  117. $temparr=explode("\$",$confile[$key+1]);
  118. $nw=substr($temparr[0],-1);
  119. if($nw==$niv)
  120. $same=true;
  121. else
  122. $same=false;
  123. if($nw<=$niv)
  124. echo "<br /><a id=\"lnk".sp($name)."\" href=\"javascript:insdom(lnk".sp($name).",'$name','$desc');\"><img id=\"img".sp($name)."\" border=0 src=\"arrow.png\" />&nbsp;$name</a>\n";
  125. else
  126. echo "<br /><a href=\"javascript:toggledom(".sp($name).",img".sp($name).");\"><img id=\"img".sp($name)."\" border=0 src=\"plus.png\" /></a>&nbsp;<a id=\"lnk".sp($name)."\" href=\"javascript:clicktoggle(lnk".sp($name).",'$name',".sp($name).",img".sp($name).",'$desc');\">$name</a>\n";
  127. echo "<div class=\"domainlist\" id=\"".sp($name)."\" style=\"display: none;\">\n";
  128. if($nw<=$niv)
  129. {
  130. $togo=$niv-$nw;
  131. for($i=0;$i<=$togo;$i++)
  132. {
  133. echo "</div>\n";
  134. }
  135. }
  136. $curniv=$niv;
  137. }
  138. ?>
  139. </div>
  140. </body>
  141. </html>

dus als je op een domein klikt weergeeftie in een ander frame de beschrijving van dat domein:
  1. <html>
  2. <head>
  3. <style>
  4. p {color: #000099; font-family: Arial,Helvetica; font-size: 12; margin-left: 10px;}
  5. </style>
  6. </head>
  7. <body bgcolor="#ffffce">
  8. <?php
  9. $title=$_GET['title'];
  10. $desc=$_GET['desc'];
  11. echo "\n<p>\n".$title.":\n<br />\n<br />\n".$desc."\n</p>";
  12. ?>
  13. </body>
  14. </html>

maar het probleem is:
bij sommige domeins weergeeftie de titel wel goed, maar bij de description zegtie [object].
het probleem ligt niet in PHP, maar in JavaScript.
Kan iemand me helpen?

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.252s