Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Alert po wygenerowaniu kodu javascript
pyrek
post
Post #1





Grupa: Zarejestrowani
Postów: 109
Pomógł: 0
Dołączył: 23.09.2003

Ostrzeżenie: (0%)
-----


Mam problem z przerobieniem tego skryptu:

http://webmaster.helion.pl/kurshtml/skrypt/doubmenu.htm


i przerabiam go na php i mysql sugerowałem się już wcześniej przedstawionym opisem na forum ale tam chyba nie udało się rozwiązać problemu:

wuwala mi cały czas alert js 'temp.options' jest pusty lub nie jest obiektem

oto kod:
  1. echo '<?xml version="1.0" encoding="iso-8859-2"?\>';
  2. ?>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
  7. <meta http-equiv="reply-to" content="Adres_e-mail" />
  8. <meta name="generator" content="WebSite PRO 4.2" />
  9. <meta name="author" content="Autor_dokumentu" />
  10. <meta name="description" content="Opis" />
  11. <title>Bez Tytułu</title>
  12. </head>
  13. <body>
  14.  
  15. <form name="doublecombo">
  16. <?php
  17.  
  18.  
  19.  
  20.  
  21. $result = mysql_query("SELECT * FROM {$pr}ogloszenia_dzial WHERE naleznosc_kat='0' and widzialnosc_kat='1' ORDER BY nazwa_kat ;") OR DIE (mysql_error());
  22.  
  23. ?>
  24.  
  25. <select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
  26.  
  27. <?php
  28. while ($row = mysql_fetch_assoc($result)) {
  29. echo '
  30. <option value="'.$row['id_kat'].'">'.$row['nazwa_kat'].'</option>
  31. ';
  32. }
  33.  
  34.  
  35. ?>
  36. </select>
  37. <select name="stage2" size="1">
  38.  
  39. <?
  40. $result1 = mysql_query("SELECT * FROM {$pr}ogloszenia_dzial WHERE naleznosc_kat='0' and widzialnosc_kat='1' ORDER BY nazwa_kat LIMIT 1") OR DIE (mysql_error());
  41. $row1 = mysql_fetch_assoc($result1) OR DIE (mysql_error());
  42.  
  43.  
  44.  
  45. $result2 = mysql_query("SELECT * FROM {$pr}ogloszenia_dzial  WHERE naleznosc_kat='$row1[id_kat]' and widzialnosc_kat='1' ORDER BY nazwa_kat") OR DIE (mysql_error());
  46.  
  47. while ($row2 = mysql_fetch_assoc($result2)) {
  48.  
  49.  
  50. echo '<option value="'.$row2['id_kat'].'">'.$row2['nazwa_kat'].'</option>';
  51.  
  52.  
  53.  
  54. }
  55. ?>
  56.  
  57. </select>
  58.  
  59.  
  60.  
  61. </form>
  62.  
  63. <?php
  64. echo '
  65. <script> 
  66. <!--
  67.  
  68. /*
  69. Double Combo Script Credit
  70. By Website Abstraction (www.wsabstract.com)
  71. Over 200+ free JavaScripts here!
  72. */
  73.  
  74. var groups=document.doublecombo.example.options.length
  75. var group=new Array(groups)
  76. for (i=0; i<groups; i++)
  77. group[i]=new Array()
  78.  
  79. ';
  80. $xl=0;
  81. $result3 = mysql_query("SELECT * FROM {$pr}ogloszenia_dzial WHERE naleznosc_kat='0' and widzialnosc_kat='1' ORDER BY nazwa_kat") OR DIE (mysql_error());
  82.  
  83. while ($row3 = mysql_fetch_assoc($result3)) {
  84.  
  85. ++$xl;
  86. $x2;
  87. $result4 = mysql_query("SELECT * FROM {$pr}ogloszenia_dzial  WHERE naleznosc_kat='$row3[id_kat]' and widzialnosc_kat='1' ORDER BY nazwa_kat");
  88.  
  89.  
  90. while ($row4 = mysql_fetch_assoc($result4) AND $i= mysql_num_rows($result3)) {
  91. ++$x2;
  92.  
  93.  
  94. echo "
  95. group['".$row3['id_kat']."']['".$row4['id_kat']."']= new Option('".$row4['nazwa_kat']."','".$row4['id_kat']."')
  96. ";
  97.  
  98.  
  99. }
  100.  
  101. }
  102. echo '
  103.  
  104. var temp=document.doublecombo.stage2
  105.  
  106.  
  107.  
  108. function redirect(x){
  109. for (m=temp.options.length-1;m>0;m--)
  110. temp.options[m]=null
  111. for (i=0;i<group[x].length;i++){
  112. temp.options[i]=new Option(group[x][i].text,group[x][i].value)
  113. }
  114. temp.options[0].selected=true
  115. }
  116.  
  117. function go(){
  118. location=temp.options[temp.selectedIndex].value
  119. }
  120.  
  121. //-->
  122. </script>
  123. ';
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 04:32