Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1724 connectés 

  FORUM HardWare.fr
  Programmation
  HTML/CSS

  Problème liste déroulante + javascript

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Problème liste déroulante + javascript

n°837771
lious
Posté le 31-08-2004 à 13:18:11  profilanswer
 

Bonjour,
 
J'ai réalisé un programme dans lequel j'ai 2 listes déroulantes : si j'actionne un élément de la 1ère liste, la seconde se met à jour et n'affiche que ce qui concerne l'élément sélectionné de la 1ère liste. Mon pb est que dans mon prog j'utilise du javascript et du PHP (pour mes requêtes à ma base de données Oracle) mais à l'exécution mes listes déroulantes n'affichent rien :ouch:. En regardant le source de la page je m'aperçoit qu'il retourne les résultats de mes requêtes mais il ne les affiche pas dans mon programme. Je vous transmet ci-dessous mon code. Si jamais vous avez des idées pourriez vous me le dire svp. Merci d'avance.

Code :
  1. <html>
  2. <head>
  3. <title>Exemple</title>
  4. <SCRIPT language="javascript">
  5. var oLogiciels = new Array();
  6. function Logiciel( idlog, nomlog)
  7. {
  8. this.idlog = idlog;
  9. this.nomlog = nomlog;
  10. this.nomversion = new Array();
  11. }
  12. Logiciel.prototype['Identificateur'] = function()
  13. {
  14. return this.idlog;
  15. }
  16. Logiciel.prototype['Nomlog'] = function()
  17. {
  18. return this.nomlog;
  19. }
  20. Logiciel.prototype['Ajouternomversion'] = function( idversion, nomversion)
  21. {
  22. this.nomversion.push( new Version(idversion, nomversion) );
  23. }
  24. function Version( idversion, nomversion )
  25. {
  26. this.idversion = idversion;
  27. this.nomversion = nomversion;
  28. }
  29. Version.prototype['Identificateur'] = function()
  30. {
  31. return this.idversion;
  32. }
  33. Version.prototype['Nom'] = function()
  34. {
  35. return this.nomversion;
  36. }
  37. function onSelect_Logiciel()
  38. {
  39. var id = oListeLogiciel.options[oListeLogiciel.selectedIndex].value;
  40. var count, count2;
  41. while (oListeVersion.options.length > 0)
  42. oListeVersion.removeChild( oListeVersion.options[0] );
  43. for (count in oLogiciels)
  44. if (oLogiciels[count].Identificateur() == id)
  45. {
  46.  for (count2 in oLogiciels[count].nomversion())
  47.  {
  48.   var oVersion = oLogiciels[count].nomversion()[count2];
  49.   var oOption = document.createElement( 'option' );
  50.   oOption.value = oVersion.Identificateur();
  51.   oOption.text = oVersion.Nom();
  52.   oListeVersion.add( oOption );
  53.  }
  54.  oListeVersion.selectedIndex = 0;
  55.  onSelect_Version();
  56.  return;
  57. }
  58. }
  59. function onSelect_Version()
  60. {
  61. var idLogiciel = oListeLogiciel.options[oListeLogiciel.selectedIndex].value;
  62. var idVersion = oListeVersion.options[oListeVersion.selectedIndex].value;
  63. var count, count2;
  64. for (count in oLogiciels)
  65. if (oLogiciels[count].Identificateur() == idLogiciel)
  66. for (count2 in oLogiciels[count].nomversion())
  67. if (oLogiciels[count].nomversion()[count2].Identificateur() == idVersion)
  68. {
  69.  var oVersion = oLogiciels[count].nomversion()[count2];
  70.  return;
  71. }
  72. }
  73. function onLoad()
  74. {
  75. var oLogiciel;
  76. var count;
  77. <?
  78. $conn = oci_connect("logitheque","logiciel",'BTEST');
  79. $sql = oci_parse($conn,'SELECT * FROM logiciel ORDER BY nomlog' );
  80. $res = oci_execute ($sql);
  81. while ($row = oci_fetch_array( $sql, OCI_BOTH ))
  82. {
  83.  echo ' oLogiciel = new Logiciel( ' . $row['IDLOG'] . ', "' . $row['NOMLOG'] . '" );';
  84.  $sql2 = oci_parse($conn, 'SELECT * FROM version');
  85.  $res2 = oci_execute ($sql2);
  86.  while ($row2 = oci_fetch_array( $sql2, OCI_BOTH)) {
  87.   echo ' oLogiciel.Ajouternomversion(' . $row2['IDVERSION'] . ', "' . $row2['NOMVERSION'] . '" );';
  88.  }
  89.  echo ' oLogiciels.push( oLogiciel );' ;
  90. }
  91. ?>
  92. for (count in oLogiciels)
  93. {
  94.  var oOption = document.createElement( 'option' );
  95.  oOption.value = oLogiciels[count].Identificateur();
  96.  oOption.text = oLogiciels[count].Nom();
  97.  oListeLogiciel.add( oOption );
  98. }
  99. onSelect_Logiciel();
  100. }
  101. </SCRIPT>
  102. </head>
  103. <BODY onload=onLoad()>
  104. <BR><SPAN
  105. style="FONT-WEIGHT: bold; FONT-SIZE: 12px; FONT-FAMILY: Verdana">Logiciel
  106. :</SPAN>  <SELECT id=oListeLogiciel
  107. style="FONT-SIZE: 10px; WIDTH: 200px; FONT-FAMILY: Verdana"
  108. onchange=onSelect_Logiciel()></SELECT><BR><BR><SPAN
  109. style="FONT-WEIGHT: bold; FONT-SIZE: 12px; FONT-FAMILY: Verdana">Version
  110. :</SPAN>  <SELECT id=oListeVersion
  111. style="FONT-SIZE: 10px; WIDTH: 200px; FONT-FAMILY: Verdana"
  112. onchange=onSelect_nomversion()></SELECT><BR><BR>
  113. </BODY>
  114. </HTML>

:ouch:  :ouch:  :ouch:

mood
Publicité
Posté le 31-08-2004 à 13:18:11  profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  HTML/CSS

  Problème liste déroulante + javascript

 

Sujets relatifs
Paramètre par defaut en javascriptProbleme HTML entre IE et Mozilla
listes déroulantes dynamiques + Oracle + Javascriptliste déroulante dynamique + oracle + php
problème pour connection a une bd depuis phppetit problème
[VBA] --> Problème rapide ( erreur de syntaxe ) [tomcat 5][datasource][mysql] Problème avec l'exemple de base...
Probleme mais pk??? 
Plus de sujets relatifs à : Problème liste déroulante + javascript


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR