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
Parth thakkar 9Parth thakkar 9 

Addding dynamicly id to page block

Giving me error multipal annotation

<apex:pageBlock id="{!pageblocksectionid}">

how can i add ?
Prabhat Kumar12Prabhat Kumar12

Unfortunatly use of daynamic ID does not support in Visualforce. There is an idea posted on salesforce for Voting. 

https://success.salesforce.com/ideaview?id=08730000000Bqu1AAC

I would suggest you go and vote for it to get it implemented.

One work around could be, which i found on google.
<apex:pageBlock  value="{!a.field_name__c}" styleClass="prefix_{!a.field_name__c}">



</apex:pageBlock >

Now use Javascript to perform your logic.

function verify(class_name) {
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++) if (inputElem[i].className == class_name) {/*do something*/}	
}

 
William TranWilliam Tran
Since what you rendered and rerender can be dynamic, I are sure you can solve whatever you need without the need for dynamic id in pageblock.

What scenarios are you trying to do that you would need a dynamic id in pageblock?

Thx
Antonio ManenteAntonio Manente
You could easily do it with Prabhat's answer and do it through javascript, or you could perhaps use a styleClass or data-attribute. As William stated, being a bit more specific and giving us your use case will enable us to give you a better answer