Bonsoir;
j'utilise jsf avec primefaces,je veux ajouter du javascript pour rendre des selectBooleanCheckbox comme des radio bouton
voilà ma page
mon fichier checkbox.js
Merci d'avance
j'utilise jsf avec primefaces,je veux ajouter du javascript pour rendre des selectBooleanCheckbox comme des radio bouton
voilà ma page
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</h:head>
<h:body>
<h:outputScript library="js" name="checkbox.js" />
<!-- ENTETE -->
<form >
<p:selectBooleanCheckbox name="A">1
</p:selectBooleanCheckbox>
<p:selectBooleanCheckbox name="A">2
</p:selectBooleanCheckbox>
<p:selectBooleanCheckbox name="A">3
</p:selectBooleanCheckbox>
<p:selectBooleanCheckbox name="A">4
</p:selectBooleanCheckbox>
</h:form>
</h:body>
</html>Code:
$("selectBooleanCheckbox").click(function() {
if ($(this).is(":checked")) {
var group = "selectBooleanCheckbox[name='" + $(this).attr("name") + "']";
$(group).prop("checked", false);
$(this).prop("checked", true);
} else {
$(this).prop("checked", false);
}
});
Aucun commentaire:
Enregistrer un commentaire