Bonjour,

Je cherche à changer du texte en fonction d'un checkbox coché ou non.
Le code suivant me paraitrait logique mais il ne marche pas.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<script language="javascript">
	function texte(id_checkbox, id)
	{
		var show;
		if (document.getElementById(id_checkbox).checked)
			show = "texte1";
		else
			show = "texte2";
		document.getElementById(id).innerHTML = show;
	}
</script>
<input type="checkbox" id="nom" /><br />
<label for="nom" onclick="texte(nom, aff);">
	<span id="aff">texte1</span>
</label>
Voyez-vous une erreur ?

Merci