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
SaranshSaransh 

Does anyone know how to fetch value of <apex:inputHidden> tag, which is repeating.

<apex:page id="pgid" standardController="Account">

<script> 
function callDelete(paramId) { 
alert(document.getElementById(paramId)); 
<b>//Need value of hidden field containing account id but during rendering <apex:inputHidden></b>
} 
</script>

<apex:form id="frmid">
      <apex:pageblock id="pgblockId">
      <apex:pageBlockSection id="pgblcksec1" >
      </apex:pageBlockSection>
          <apex:pageBlockSection id="pgblcksec2">
              <apex:pageBlockTable id="pgblcktb" value="{!lst}" var="acc">
                  <apex:column value="{!acc.name}"/>
                  <apex:column value="{!acc.type}"/>
                  <apex:column value="{!acc.phone}"/>
                  <apex:inputHidden value="{!acc.id}" id="hdnaccid"/>
                  <apex:column >
                      <apex:commandButton id="cmdId" onclick="callDelete('{!$Component.hdnaccid}');" value="Delete"/>
                  </apex:column>
          </apex:pageBlockTable>
       </apex:pageBlockSection>
      </apex:pageblock>
      </apex:form>
</apex:page>
Best Answer chosen by Saransh
Zuinglio Lopes Ribeiro JúniorZuinglio Lopes Ribeiro Júnior
Hello,

Try placing it inside one of your columns:
 
<apex:page id="pgid" standardController="Account">
    
    <script> 
    function callDelete(paramId) { 
        alert(document.getElementById(paramId)); 
        <b>//Need value of hidden field containing account id but during rendering <apex:inputHidden></b>
    } 
        </script>
    
    <apex:form id="frmid">
        <apex:pageblock id="pgblockId">
            <apex:pageBlockSection id="pgblcksec1" >
            </apex:pageBlockSection>
            <apex:pageBlockSection id="pgblcksec2">
                <apex:pageBlockTable id="pgblcktb" value="{!lst}" var="acc">
                    <apex:column value="{!acc.name}"/>
                    <apex:column value="{!acc.type}"/>
                    <apex:column value="{!acc.phone}"/>
                    <apex:column >
                        <apex:inputHidden value="{!acc.id}" id="hdnaccid"/>
                        <apex:commandButton id="cmdId" onclick="callDelete('{!$Component.hdnaccid}');" value="Delete"/>
                    </apex:column>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>

Regards.

Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.

All Answers

Zuinglio Lopes Ribeiro JúniorZuinglio Lopes Ribeiro Júnior
Hello,

Try placing it inside one of your columns:
 
<apex:page id="pgid" standardController="Account">
    
    <script> 
    function callDelete(paramId) { 
        alert(document.getElementById(paramId)); 
        <b>//Need value of hidden field containing account id but during rendering <apex:inputHidden></b>
    } 
        </script>
    
    <apex:form id="frmid">
        <apex:pageblock id="pgblockId">
            <apex:pageBlockSection id="pgblcksec1" >
            </apex:pageBlockSection>
            <apex:pageBlockSection id="pgblcksec2">
                <apex:pageBlockTable id="pgblcktb" value="{!lst}" var="acc">
                    <apex:column value="{!acc.name}"/>
                    <apex:column value="{!acc.type}"/>
                    <apex:column value="{!acc.phone}"/>
                    <apex:column >
                        <apex:inputHidden value="{!acc.id}" id="hdnaccid"/>
                        <apex:commandButton id="cmdId" onclick="callDelete('{!$Component.hdnaccid}');" value="Delete"/>
                    </apex:column>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>

Regards.

Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
This was selected as the best answer
Zuinglio Lopes Ribeiro JúniorZuinglio Lopes Ribeiro Júnior
Hello,

I suppose that your class is not finished yet. You will need an extension controller or similar that has a List of Account (lst) to populate your pageBlockTable.

Regards.

Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
SaranshSaransh
Thanks Zuinglio, I was banging my head from past 30minutes, that why is this not working. I should have posted it here before :)
Zuinglio Lopes Ribeiro JúniorZuinglio Lopes Ribeiro Júnior
Glad to have helped :)