Accueil > Forum > > > > gestion evenements souris
gestion evenements souris
jeudi 20 mars 2003 à 14:02:40 |
gestion evenements souris

bside8
|
Bonjour, j'essaie depuis un sacré moment de faire fonctionner le code qui suit...(récupéré dans la source de MySQL) Impossible de le faire tourner !!! L'objectif, comme dans MySQL, est de présenter des résultats de requête dans un tableau et d'en faciliter la visibilité et la lecture. Théoriquement, le fait de passer le pointeur de la souris sur une ligne doit la faire devenir verte ; la sélectionner : orange. Qq'1 peut-il me dépanner ? Merci <?php echo "<html><head><title>Test variation couleurs des lignes</title></head>"; echo "<body>"; echo "<table border=0 cellspacing=0 cellpadding=0>"; echo "<tr onmouseover=\"setPointer(this, 'over', '#DDDDDD', '#CCFFCC', '#FFCC99')\" onmouseout=\"setPointer(this, 'out', '#DDDDDD', '#CCFFCC', '#FFCC99')\" onmousedown=\"setPointer(this, 'click', '#DDDDDD', '#CCFFCC', '#FFCC99')\"><td bgcolor=\"#DDDDDD\">a</td><td bgcolor=\"#DDDDDD\">b</td><td bgcolor=\"#DDDDDD\">c</td></tr>"; echo "<tr onmouseover=\"setPointer(this, 'over', '#DDDDDD', '#CCFFCC', '#FFCC99')\" onmouseout=\"setPointer(this, 'out', '#DDDDDD', '#CCFFCC', '#FFCC99')\" onmousedown=\"setPointer(this, 'click', '#DDDDDD', '#CCFFCC', '#FFCC99')\"><td bgcolor=\"#DDDDDD\">1</td><td bgcolor=\"#DDDDDD\">2</td><td bgcolor=\"#DDDDDD\">3</td></tr>"; echo "<tr onmouseover=\"setPointer(this, 'over', '#DDDDDD', '#CCFFCC', '#FFCC99')\" onmouseout=\"setPointer(this, 'out', '#DDDDDD', '#CCFFCC', '#FFCC99')\" onmousedown=\"setPointer(this, 'click', '#DDDDDD', '#CCFFCC', '#FFCC99')\"><td bgcolor=\"#DDDDDD\">4</td><td bgcolor=\"#DDDDDD\">5</td><td bgcolor=\"#DDDDDD\">6</td></tr>"; echo "<tr onmouseover=\"setPointer(this, 'over', '#DDDDDD', '#CCFFCC', '#FFCC99')\" onmouseout=\"setPointer(this, 'out', '#DDDDDD', '#CCFFCC', '#FFCC99')\" onmousedown=\"setPointer(this, 'click', '#DDDDDD', '#CCFFCC', '#FFCC99')\"><td bgcolor=\"#DDDDDD\">d</td><td bgcolor=\"#DDDDDD\">e</td><td bgcolor=\"#DDDDDD\">f</td></tr>"; echo "</table>"; echo "</body>"; echo "</html>"; ?>
|
|
|
mercredi 30 juillet 2003 à 14:44:31 |
La solution... ou pas !

LeMalinou
|
Salut ! J'etais dans le même cas que toi et je voulais utiliser cette fameuse fonction "setPointer" mais pas moyen que mes lignes changent de couleur !!! Alors en fouillant un peu sur le net j'ai trouvé le code du script correspondant à l'adresse: http://cutephp.com/forum/index.php?s=c6b180ce7056fec22777dcebf020fd95&showtopic=1582&st=0entry6852 Donc je t'avoue je n'ai aucun mérite  Par contre j'ai modifié un peu le code car chez moi ca marchait pas parfaitement: /** * Sets/unsets the pointer and marker in browse mode * * @param object the table row * @param integer the row number * @param string the action calling this script (over, out or click) * @param string the default background color * @param string the color to use for mouseover * @param string the color to use for marking a row * * @return boolean whether pointer is set or not */ function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor) { var theCells = null; // 1. Pointer and mark feature are disabled or the browser can't get the // row -> exits if ((thePointerColor == '' && theMarkColor == '') || typeof(theRow.style) == 'undefined') { return false; } // 2. Gets the current row and exits if the browser can't get it if (typeof(document.getElementsByTagName) != 'undefined') { theCells = theRow.getElementsByTagName('td'); } else if (typeof(theRow.cells) != 'undefined') { theCells = theRow.cells; } else { return false; }
// 3. Gets the current color... var rowCellsCnt = theCells.length; var domDetect = null; var currentColor = null; var newColor = null; var marked_row = new Array(); // 3.1 ... with DOM compatible browsers except Opera that does not return // valid values with "getAttribute" if (typeof(window.opera) == 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') { currentColor = theCells[0].getAttribute('bgcolor'); domDetect = true; } // 3.2 ... with other browsers else { currentColor = theCells[0].style.backgroundColor; domDetect = false; } // end 3 // 4. Defines the new color // 4.1 Current color is the default one if (currentColor == '' || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) { if (theAction == 'over' && thePointerColor != '') { newColor = thePointerColor; } else if (theAction == 'click' && theMarkColor != '') { newColor = theMarkColor; } } // 4.1.2 Current color is the pointer one else if (currentColor == thePointerColor.toLowerCase() || currentColor.toLowerCase() == thePointerColor.toLowerCase() && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) { if (theAction == 'out') { newColor = theDefaultColor; } else if (theAction == 'click' && theMarkColor != '') { newColor = theMarkColor; marked_row[theRowNum] = true; } } // 4.1.3 Current color is the marker one else if (currentColor == theMarkColor.toLowerCase() ||currentColor.toLowerCase() == theMarkColor.toLowerCase()) { if (theAction == 'click') { newColor = (thePointerColor != '') ? thePointerColor : theDefaultColor; marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum]) ? true : null; } } // end 4 // 5. Sets the new color... if (newColor) { var c = null; // 5.1 ... with DOM compatible browsers except Opera if (domDetect) { for (c = 0; c < rowCellsCnt; c++) { theCells[c].setAttribute('bgcolor', newColor, 0); } // end for } // 5.2 ... with other browsers else { for (c = 0; c < rowCellsCnt; c++) { theCells[c].style.backgroundColor = newColor; } } } // end 5 return true; } // end of the 'setPointer()' function
|
A verifier tout de même... Et tu l'appelles avec: onmouseXXX="setPointer(this, <id_row>, 'XXX', '#DDDDDD', '#CCFFCC', '#FFCC99')" avec XXX = over, out, down ! <id_row> est le numero de la ligne Et j'ai à mon tour une question:Comment récuperer ensuite le tableau "marked_row" qui contient les id de toutes les lignes selectionnées ? Si je change les "return true" en "return marked_row" ??? Et même dans ce cas, comment je les recupere ensuite dans une variable php car l'appel de la fonction "setPointer" se fait pour une action "onmouse...=" ??? Dsl pour les questions stupides mais c ma 1ere utilisation de script 
|
|
mercredi 7 février 2007 à 11:17:00 |
Re : gestion evenements souris

monoar
|
Le code de LeMalinou est parfait. Il fonctionne très bien chez moi : MERCI Aurore.
|
|
Cette discussion est classée dans : code, gestion, souris, evenements, echo
Répondre à ce message
Livres en rapport
|
Derniers Blogs
JOYEUX ANNIVERSAIRE NIXJOYEUX ANNIVERSAIRE NIX par ebartsoft
Souhaitons un bon et joyeux anniversaire à notre hôte à tous, Nix.
Je ne le répéterais jamais assez mais sans lui rien ne serait possible. Il défit en permanence les lois de la gravité et comme il le dit si bien, si tu lui fais confiance ça devra...
Cliquez pour lire la suite de l'article par ebartsoft IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc
Forum
UTILISER UN .JSUTILISER UN .JS par zaikoe
Cliquez pour lire la suite par zaikoe
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|