You need to sign in to do that
Don't have an account?
Venky5599
Limited number of selections for a check box
HI All
i have a page block table in that table i have all the Account and Check box for each Account .
i need to controlle the user when he is selecting the Check boxes.
means user should not select more the one check box at a time can you please help me for this?
Thanks
Pradeep.G
Hi,
Try the below code snippet as reference:
***************vf page code****************
<apex:page controller="abc1">
<script>
function checkone(cb)
{
var countchbox=0;
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++)
{
if(inputElem[i].id.indexOf("checkedone")!=-1)
{
if(inputElem[i].checked ==true)
{
inputElem[i].checked=false;
}
}
}
cb.checked = true;
}
</script>
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!fieldsvalues}" var="mp1" id="pbt">
<apex:column >
<input type="checkbox" name="{!mp1.id}" id="checkedone" onclick="return checkone(this)"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
***************** apex class code****************
public class abc1
{
public List<contact> fieldsvalues{get;set;}
public abc1()
{
fieldsvalues=[select id,Name,email, firstname from contact ];
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
All Answers
Hi,
Try the below code snippet as reference:
***************vf page code****************
<apex:page controller="abc1">
<script>
function checkone(cb)
{
var countchbox=0;
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++)
{
if(inputElem[i].id.indexOf("checkedone")!=-1)
{
if(inputElem[i].checked ==true)
{
inputElem[i].checked=false;
}
}
}
cb.checked = true;
}
</script>
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!fieldsvalues}" var="mp1" id="pbt">
<apex:column >
<input type="checkbox" name="{!mp1.id}" id="checkedone" onclick="return checkone(this)"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
***************** apex class code****************
public class abc1
{
public List<contact> fieldsvalues{get;set;}
public abc1()
{
fieldsvalues=[select id,Name,email, firstname from contact ];
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
HI Thank a lot
Can you please help ihave one more dout
http://boards.developerforce.com/t5/Apex-Code-Development/Editing-the-Account-using-the-check-box/m-p/442347
click on the above link and send me the solution because iam trying form past ten days but no result
Thank
Pradeep.G