Affichage d'un champ en fonction du checkbox
Bonjour tout le monde,
J'aimerai pouvoir afficher un contenu (un champ d'un formulaire) en fonction si le checkbox est cocher ou décocher.
ci-dessous mon code (qui ne marche pas et je ne sais pas pourquoi: mon bouton checkbox cocher ou décocher n'a aucun effet sur l'affichage ou non de mon champ de formulaire)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Formulaire JSF2.0</title>
<link rel="stylesheet" type="text/css" href="/style.css"></link>
</h:head>
<h:body>
<h:form>
<h:selectBooleanCheckbox id="chartDept" title="chartDept" onclick="showCheck()"></h:selectBooleanCheckbox>
<h:outputText value="By Dept "/>
<pre id="deptPie" style="display: none">
<p:pieChart value="#{pieBean.pieModelDept}" legendPosition="w" title="Model dept" style="width:500px;height:410px" />
</pre>
<script type="text/javascript">
//<![CDATA[
function showCheck() {
if (document.getElementById('j_idt6:chartDept').checked) == true) {
document.getElementById('deptPie').style.display = "block";
}
else {
document.getElementById('deptPie').style.display = "none";
}
};
//]]>
</script>
</h:form>
</h:body>
</html> |
Quelqu'un peux me débloquer SVP ?
Merci par avance