You need to sign in to do that
Don't have an account?

select the inputcheckbox get the index or row id
hai all
on vfpage i have 4 inputcheckbox, if i selected checkbox 1 add to integer and then display the selected seat is 1 and if i selected checkbox 3 add to integer and then display the selected seat is 3 Iwant display the statically or dynamically
i wrote the code
it will count the noof seats
public class adds {
public integer count{set;get;}
public boolean book1{set;get;}
public boolean book2{set;get;}
public boolean book3{set;get;}
public boolean book4{set;get;}
public boolean book5{set;get;}
public integer index{set;get;}
public adds(){
count=0;
}
public void add1(){
if(book1==true){
count=count+1;
index=1;
}else if(book2==true){
count=count+1;
index=2;
}else if(book3==true){
count=count+1;
}else if(book4==true){
count=count+1;
}else if(book5==true){
count=count+1;
}
}
}
vfpage
<apex:page controller="adds" >
<apex:form >
<apex:pageblock id="one">
<apex:inputCheckbox value="{!book1}">
<apex:actionsupport event="onchange" action="{!add1}" rerender="one"/>
</apex:inputCheckbox>
<apex:inputCheckbox value="{!book2}"><apex:actionsupport event="onchange" action="{!add1}" rerender="one"/>
</apex:inputCheckbox>
<apex:inputCheckbox value="{!book3}"><apex:actionsupport event="onchange" action="{!add1}" rerender="one"/>
</apex:inputCheckbox>
<apex:inputCheckbox value="{!book4}"><apex:actionsupport event="onchange" action="{!add1}" rerender="one"/>
</apex:inputCheckbox>
<apex:inputCheckbox value="{!book5}"><apex:actionsupport event="onchange" action="{!add1}" rerender="one"/>
</apex:inputCheckbox>
{!count} selected seats{!index}
</apex:pageblock>
</apex:form>
</apex:page>
on vfpage i have 4 inputcheckbox, if i selected checkbox 1 add to integer and then display the selected seat is 1 and if i selected checkbox 3 add to integer and then display the selected seat is 3 Iwant display the statically or dynamically
i wrote the code
it will count the noof seats
public class adds {
public integer count{set;get;}
public boolean book1{set;get;}
public boolean book2{set;get;}
public boolean book3{set;get;}
public boolean book4{set;get;}
public boolean book5{set;get;}
public integer index{set;get;}
public adds(){
count=0;
}
public void add1(){
if(book1==true){
count=count+1;
index=1;
}else if(book2==true){
count=count+1;
index=2;
}else if(book3==true){
count=count+1;
}else if(book4==true){
count=count+1;
}else if(book5==true){
count=count+1;
}
}
}
vfpage
<apex:page controller="adds" >
<apex:form >
<apex:pageblock id="one">
<apex:inputCheckbox value="{!book1}">
<apex:actionsupport event="onchange" action="{!add1}" rerender="one"/>
</apex:inputCheckbox>
<apex:inputCheckbox value="{!book2}"><apex:actionsupport event="onchange" action="{!add1}" rerender="one"/>
</apex:inputCheckbox>
<apex:inputCheckbox value="{!book3}"><apex:actionsupport event="onchange" action="{!add1}" rerender="one"/>
</apex:inputCheckbox>
<apex:inputCheckbox value="{!book4}"><apex:actionsupport event="onchange" action="{!add1}" rerender="one"/>
</apex:inputCheckbox>
<apex:inputCheckbox value="{!book5}"><apex:actionsupport event="onchange" action="{!add1}" rerender="one"/>
</apex:inputCheckbox>
{!count} selected seats{!index}
</apex:pageblock>
</apex:form>
</apex:page>
Please find the following solution which is tested -
Controller Class:
Apex Page:
------------
Thanks,
Srinivas
- Please mark as solution if your problem is resolved.