nougitch
Messages postés431Date d'inscriptionmercredi 22 octobre 2003StatutMembreDernière intervention17 novembre 2008
-
2 mars 2005 à 15:50
patrick72 -
18 juin 2014 à 13:46
Bonjour,
Je possède un tableau.
J'aimerai que quand je clique sur une donnée elle se colore.
Quand quand je reclique dessus, elle retrouve sa couleur initiale.
Et que je puisse en sélectionner plusieurs (en colorier plusieurs).
Je veux également que quand je passe au dessus d'une ligne avec la
souris, elle se colore et bien sûr, que quand je quitte la ligne
(toujours avec la souris) elle retrouve sa couleur initiale.
En sachant que mon tableau (même si ce n'est pas le cas dans l'exemple possède des couleurs alternées).
J'aimerai refaire la même chose que dans PhpMyAdmin pour ceux qui voit ce que je veux dire.
Merci mille fois à ceux qui pourront m'aider.
Plusieurs personnes m'ont donnée des éléments de réponse mais je n'arrive pas compiler le tout !
Voici ce que j'ai :
---------------------------------------------
Javascript : general.js
---------------------------------------------
function rowOverEffect(object) {
if (object.className 'dataTableRow') object.className 'dataTableRowOver';
}
function rowOutEffect(object) {
if (object.className 'dataTableRowOver') object.className 'dataTableRow';
ehmarc
Messages postés393Date d'inscriptionmardi 2 décembre 2003StatutMembreDernière intervention29 septembre 2008 2 mars 2005 à 22:23
Salut
Va voire du coter Javascript
Bon vu que tu est dans la m...
/**
* Sets/unsets the pointer and marker in browse mode
*
* @param object the table row
* @param interger 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;
// 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;
marked_row[theRowNum] = true;
}
}
// 4.1.2 Current color is the pointer one
else if (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.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
C'est pas du tout le script (ironie) qu'il y a dans phpmyadmin
ensuite sur tes lignes
surtout tu as un chiffre (0 sur le premier et 1 sur le second) il ne faut surtout pas oublier de l'incrementer au fur et a mesure de tes ligne sinon ca va planter le reste c'est des couleurs
bon courage
++
"Aucun de nous ne sait ce que nous savons tous, ensemble."
Lao Tseu inventeur du "copier coller"
nougitch
Messages postés431Date d'inscriptionmercredi 22 octobre 2003StatutMembreDernière intervention17 novembre 2008 3 mars 2005 à 11:28
Bonjour et merci pour vos réponses !
J'ai essayé les deux :
--> ehmarc : je n'ai pas réussi à la faire
fonctionner. J'ai regarder dans PHPMyAdmin. En effet, la fonction est
correcte mais dans un cas concret, elle ne fonctione pas.
Peux-tu me montrer un exemple HTML qui fonctionne avec cette fonction.
--> Anthomicro : Cela fonctionne
aussi mais je n'ai pas la surbrillance avec le "onmouseover" et
surtout, le fait que mon tableau est composé de couleurs alternées.
cs_Anthomicro
Messages postés9433Date d'inscriptionmardi 9 octobre 2001StatutMembreDernière intervention13 avril 20078 3 mars 2005 à 13:02
Salut,
tu peux nous passer ton code html (un petit bout), ensuite les couleurs sont alternées d'origine ?
Tu veux que la couleur change sur un onmouseover ? il aurait fallu le
faire en CSS mais bon, IE ne gère pas le hover si c'est pas pour un
lien va encore falloir faire du JS...
cs_Anthomicro
Messages postés9433Date d'inscriptionmardi 9 octobre 2001StatutMembreDernière intervention13 avril 20078 3 mars 2005 à 13:27
Ouch, c'est long...
remplis ton code html sans php avec un peu de texte et les couleurs
d'origine (deux lignes de cellules histoire de voir la différence, et
précise ce que tu souhaites directement stp)
par exemple : la couleur qui change quand on clique, c'est fait (voir code JS plus haut)
Tu veux également que lorsqu'on passe la souris ça change de couleur,
et lorsqu'on enlève la souris ça reprend la couleur lorsque tu avais
cliqué dessus, c'est ça ?
ehmarc
Messages postés393Date d'inscriptionmardi 2 décembre 2003StatutMembreDernière intervention29 septembre 2008 3 mars 2005 à 13:50
Salut
voila j'ai pas tester mais comme je l'ai deja implanter sur mon site avec succès je pense que ce petit bout de code va marcher
<script language="JavaScript" type="text/javascript">
//ici tu met le script que je t'ai mis
</script>
<?php
include("_connexion.php");
echo "<form method='post' action='application_add.php'>
Application
Spoken language
Written language
</form>
";
if($_GET['erreur'] == 1) {
echo "
Error : you didn't enter the application's name !
";
}
elseif($_GET['erreur'] == 2) {
echo "
Error : you didn't select the application's type !
ehmarc
Messages postés393Date d'inscriptionmardi 2 décembre 2003StatutMembreDernière intervention29 septembre 2008 3 mars 2005 à 17:44
re:
bon ca j'ai tester j'ai simplifier au maximum :
<script language="JavaScript" type="text/javascript">
/* 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 -> exitsif ((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 oneelse 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 oneelse 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
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Document sans titre</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
ehmarc
Messages postés393Date d'inscriptionmardi 2 décembre 2003StatutMembreDernière intervention29 septembre 2008 4 mars 2005 à 10:31
Salut
Perso j'ai pas fait grand chose j'ai juste pomper du code de phpmyadmin...
Par contre, vu que ne connais pas du tout firefox (je developpe en interne) donc je ne pourrai pas t'aider pour une adaptation du code
Faut que je passe sur firefox chez moi histoire de le tester!!!!
++
"Aucun de nous ne sait ce que nous savons tous, ensemble."
Lao Tseu inventeur du "copier coller"
ehmarc
Messages postés393Date d'inscriptionmardi 2 décembre 2003StatutMembreDernière intervention29 septembre 2008 4 mars 2005 à 11:54
Salut
Question bete : Ca marche les changements et tout le bastringue de phpmyadmin sous firefox??? si oui il doit y avoir une raison dans le code!!!!
sinon bin ..... heu .... c'est à dire que.... tu teste l'explorersous ie t'execute le mien et sous firefox celui d'antomicro (koi j'ai dit une connerie je sais pas ou)
++
"Aucun de nous ne sait ce que nous savons tous, ensemble."
Lao Tseu inventeur du "copier coller"
ehmarc
Messages postés393Date d'inscriptionmardi 2 décembre 2003StatutMembreDernière intervention29 septembre 2008 4 mars 2005 à 14:20
Bin donc si le script que je t'ai passer ne marche pas la c'est qu'il doit avoir une fonction qui traine quelques part dans phpmyadmin et qui permet de faire quelques chose de compatible ya pu qua chercher.
++
"Aucun de nous ne sait ce que nous savons tous, ensemble."
Lao Tseu inventeur du "copier coller"