Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display fields according to a value in an other
    primarykey
    data
    text
    <p>I've got one head scratcher of a problem that I can't seem to find a solution for.</p> <p>I'm doing a VF page in witch I want to display fields according to a number inserted by user in an other fields. For example, if the user insert 2 in the field "A" it will display two fields in the same page.</p> <pre><code>// Page &lt;apex:page standardController="Assure__c" extensions="insEnfant" standardStylesheets="true"&gt; &lt;apex:sectionHeader title="Ajouter un assuré" subtitle="{!$User.FirstName}" help="/help/doc/user_ed.jsp?loc=help"&gt;&lt;/apex:sectionHeader&gt; &lt;apex:form&gt; &lt;apex:pageBlock title="Nouveau assuré" id="thePageBlock" mode="edit"&gt; &lt;apex:pageBlockButtons&gt; &lt;apex:commandButton action="{!save}" value="Enregistrer"&gt;&lt;/apex:commandButton&gt; &lt;apex:commandButton action="{!cancel}" value=" Annuler "&gt;&lt;/apex:commandButton&gt; &lt;/apex:pageBlockButtons&gt; &lt;apex:pageBlockSection title="General Information" columns="2"&gt; &lt;apex:pageBlockSection id="liste1" columns="1"&gt; &lt;apex:inputField value="{!Assure__c.Civilite__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Nom__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Prenom__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Nom_de_jeune_fille__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Date_de_naissance__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Lieu_de_naissance__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Pays_de_naissance__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Nationalit__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Situation_Familiale__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Numero_de_securit_sociale__c}"&gt;&lt;/apex:inputField&gt; &lt;/apex:pageBlockSection&gt; &lt;apex:pageBlockSection id="liste2" columns="1"&gt; &lt;apex:inputField value="{!Assure__c.Telephone_bureau__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Telephone_personnel__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Portable__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Adresse_e_mail__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Adresse__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Code_postal__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Ville__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Pays__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Pays__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:pageBlockSectionItem&gt; &lt;apex:outputLabel value="Nombre d'enfants" /&gt; &lt;apex:outputPanel&gt; &lt;apex:inputField value="{!Assure__c.Nombre_enfants__c}"&gt; &lt;apex:actionSupport event="onchange" rerender="thePageBlock" status="statut1" /&gt; &lt;/apex:inputField&gt; &lt;apex:actionStatus startText="Application..." id="statut1" /&gt; &lt;/apex:outputPanel&gt; &lt;/apex:pageBlockSectionItem&gt; &lt;apex:pageBlockSectionItem&gt; &lt;apex:outputLabel value="{!$ObjectType.Assure__c.fields.Etudes_superieures__c.label}" /&gt; &lt;apex:outputPanel&gt; &lt;apex:inputField value="{!Assure__c.Etudes_superieures__c}"&gt; &lt;apex:actionSupport event="onchange" rerender="thePageBlock" status="statut2" /&gt; &lt;/apex:inputField&gt; &lt;apex:actionStatus startText="Application..." id="statut2" /&gt; &lt;/apex:outputPanel&gt; &lt;/apex:pageBlockSectionItem&gt; &lt;apex:pageBlockSectionItem&gt; &lt;apex:outputLabel value="Service militaire" /&gt; &lt;apex:outputPanel&gt; &lt;apex:inputField value="{!Assure__c.Service_militaire__c}"&gt; &lt;apex:actionSupport event="onchange" rerender="thePageBlock" status="statut3" /&gt; &lt;/apex:inputField&gt; &lt;apex:actionStatus startText="Application..." id="statut3" /&gt; &lt;/apex:outputPanel&gt; &lt;/apex:pageBlockSectionItem&gt; &lt;/apex:pageBlockSection&gt; &lt;/apex:pageBlockSection&gt; &lt;apex:pageBlockSection title="Entrez le niveau d'études supérieures atteint" columns="1" rendered="{!(Assure__c.Etudes_superieures__c)}"&gt; &lt;apex:inputField value="{!Assure__c.Type_etudes__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Diplome_obtenu__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Nombre_annees__c}"&gt;&lt;/apex:inputField&gt; &lt;/apex:pageBlockSection&gt; &lt;apex:pageBlockSection title="Entrez les informations concernant le service militaire" columns="1" rendered="{!(Assure__c.Service_militaire__c)}"&gt; &lt;apex:inputField value="{!Assure__c.Type_de_service__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Date_de_debut__c}"&gt;&lt;/apex:inputField&gt; &lt;apex:inputField value="{!Assure__c.Date_de_fin__c}"&gt;&lt;/apex:inputField&gt; &lt;/apex:pageBlockSection&gt; &lt;apex:pageBlockSection title="Liste des enfants" columns="1" rendered="{!IF(Assure__c.Nombre_enfants__c &gt; 0, true, false)}"&gt; &lt;apex:pageBlockTable value="{!accts}" var="a" id="table"&gt; &lt;apex:facet name="footer"&gt; &lt;apex:commandLink value="Ajouter" action="{!addRow}" rerender="table,error" /&gt; &lt;/apex:facet&gt; &lt;apex:column headerValue="Nom"&gt; &lt;apex:inputField value="{!a.Name}" /&gt; &lt;/apex:column&gt; &lt;apex:column headerValue="Prénom"&gt; &lt;apex:inputField value="{!a.Prenom__c}" /&gt; &lt;/apex:column&gt; &lt;apex:column headerValue="Né le"&gt; &lt;apex:inputField value="{!a.Date_de_naissance__c}" /&gt; &lt;/apex:column&gt; &lt;apex:column headerValue="Lieu de naissance"&gt; &lt;apex:inputField value="{!a.Lieu_de_naissance__c}" /&gt; &lt;/apex:column&gt; &lt;apex:column headerValue="Situation"&gt; &lt;apex:inputField value="{!a.Situation__c }" /&gt; &lt;/apex:column&gt; &lt;/apex:pageBlockTable&gt; &lt;/apex:pageBlockSection&gt; &lt;/apex:pageblock&gt; &lt;/apex:form&gt; &lt;/apex:page&gt; // Controller public class insEnfant{ public List&lt;Enfants__c&gt; accts {get; set;} public insererEnfant(){ accts = new List&lt;Enfants__c&gt;(); accts.add(new Enfants__c()); } public void addrow(){ accts.add(new Enfants__c()); } public PageReference save(){ insert accts; PageReference home = new PageReference('/home/home.jsp'); home.setRedirect(true); return home; } } </code></pre> <p>Can anyone help me please ?</p> <p>Thanks !!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload