par
Cyrano » 03 mai 2006, 08:56
Il doit manquer quelque chose quelque part, je viens de procéder à un petit test qui fonctionne parfaitement, ce bout de code t'aidera peut-être à trouver une solution:
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" xml:lang="fr" />
<title>Changer la classe CSS d'un élément</title>
<meta http-equiv="Content-language" content="FR-fr" xml:lang="fr" dir="ltr" />
<style type="text/css">
/* <![CDATA[ */
.normal {
color: #000;
background-color: #fff;
}
.input_error {
color: #ccc;
background-color: #c00;
}
/* ]]> */
</style>
<script type="text/javascript">
/* <![CDATA[ */
function changeTextarea()
{
var propTextarea = document.getElementById('title').className;
document.getElementById('title').className = (propTextarea == '' || propTextarea == 'normal') ? 'input_error' : 'normal';
}
/* ]]> */
</script>
</head>
<body>
<form id="mon_formulaire" action="" method="post">
<textarea name="title" cols="50" rows="2" id="title">Du texte juste pour illustrer le fonctionnement.</textarea>
</form>
<p><a href="#" class="" title="Changer la classe CSS du Textarea" onclick="changeTextarea();">Changer la classe CSS du Textarea</a></p>
</body>
</html>
Il doit manquer quelque chose quelque part, je viens de procéder à un petit test qui fonctionne parfaitement, ce bout de code t'aidera peut-être à trouver une solution:
[php]<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" xml:lang="fr" />
<title>Changer la classe CSS d'un élément</title>
<meta http-equiv="Content-language" content="FR-fr" xml:lang="fr" dir="ltr" />
<style type="text/css">
/* <![CDATA[ */
.normal {
color: #000;
background-color: #fff;
}
.input_error {
color: #ccc;
background-color: #c00;
}
/* ]]> */
</style>
<script type="text/javascript">
/* <![CDATA[ */
function changeTextarea()
{
var propTextarea = document.getElementById('title').className;
document.getElementById('title').className = (propTextarea == '' || propTextarea == 'normal') ? 'input_error' : 'normal';
}
/* ]]> */
</script>
</head>
<body>
<form id="mon_formulaire" action="" method="post">
<textarea name="title" cols="50" rows="2" id="title">Du texte juste pour illustrer le fonctionnement.</textarea>
</form>
<p><a href="#" class="" title="Changer la classe CSS du Textarea" onclick="changeTextarea();">Changer la classe CSS du Textarea</a></p>
</body>
</html>[/php]