function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ethan huntethan hunt 

Checkbox click to redirect to account page

Hi All,

 

Could you please help me in achieveing the following.

 

1. VF page has all account name with checkbox.

2. On checkbox click on VF page it should redirect to the account page detail of that record.

 

Regards.

Avidev9Avidev9
post some code.
ethan huntethan hunt

<apex:page standardController="Account" recordSetVar="accounts" tabStyle="Opportunity" sidebar="false" >

<script>
function hello()
{
var x = document.getElementById('cd').checked;

if (x == "")
{
alert("Please select");
return false;
}
window.open('https://c.ap1.visual.force.com/apex/standardcontroller?id={!Account.id}');
}
</script>
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton action="{!edit}" value="Edit"/>
<apex:commandButton action="{!delete}" value="Delete"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
<apex:commandButton value="Quick Save" action="{!quicksave}"/>
<apex:commandButton value="List" action="{!list}"/>
<apex:commandButton value="check deatil" onclick="hello()"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!accounts}" var="a">

<apex:column headerValue="Name">
<apex:outputLink value="/{!a.Id}" target="_blank">{!a.Name}</apex:outputLink>

</apex:column>
<apex:column headerValue="CheckBox Action" >
<apex:inputCheckbox value="{!a.name}" style="position:absolute;left:900px;" id="cd" >{!a.Name}</apex:inputCheckbox>
</apex:column>
</apex:pageBlockTable>

<apex:pageBlockSection title="Selected Account" id="sa" collapsible="true">
<apex:DataTable value="{!accounts}" var="s" columnswidth="50px,50px" cellpadding="4" border="1">
<apex:column headervalue="Account Name" value="{!s.Name}" />
<apex:column headervalue="Account Number" value="{!s.AccountNumber}" />
<apex:column headervalue="Phone" value="{!s.Phone}" />
</apex:DataTable>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:form>
</apex:page>

Avidev9Avidev9

Try this

 

<apex:page standardController="Account" recordSetVar="accounts" tabStyle="Opportunity" sidebar="false" >
  
   <apex:form >
      <apex:pageBlock mode="edit">
         <apex:pageMessages />
         <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton action="{!edit}" value="Edit"/>
            <apex:commandButton action="{!delete}" value="Delete"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
            <apex:commandButton value="Quick Save" action="{!quicksave}"/>
            <apex:commandButton value="List" action="{!list}"/>
            <apex:commandButton value="check deatil" onclick="hello()"/>
         </apex:pageBlockButtons>
         <apex:pageBlockTable value="{!accounts}" var="a">
            <apex:column headerValue="Name">
               <apex:outputLink value="/{!a.Id}" target="_blank">{!a.Name}</apex:outputLink>
            </apex:column>
            <apex:column headerValue="CheckBox Action" >
               <apex:inputCheckbox value="{!a.name}" style="position:absolute;left:900px;" id="cd" onclick="window.open('https://c.ap1.visual.force.com/{!a.id}');">{!a.Name}</apex:inputCheckbox>
            </apex:column>
         </apex:pageBlockTable>
         <apex:pageBlockSection title="Selected Account" id="sa" collapsible="true">
            <apex:DataTable value="{!accounts}" var="s" columnswidth="50px,50px" cellpadding="4" border="1">
               <apex:column headervalue="Account Name" value="{!s.Name}" />
               <apex:column headervalue="Account Number" value="{!s.AccountNumber}" />
               <apex:column headervalue="Phone" value="{!s.Phone}" />
            </apex:DataTable>
         </apex:pageBlockSection>
      </apex:pageBlock>
   </apex:form>
</apex:page>