You need to sign in to do that
Don't have an account?
Xisco
getElementById - Not working when static resource file is included
Hi All,
I having a trouble when getting a value from a visualforce page element.
when I do this:
<apex:page> <apex:form id="theForm"> <apex:pageblock id="thePageBlock" title="pageBlock"> <apex:inputHidden id="StrTestId" value="{!Test__c.Id}"/> </apex:pageblock> </apex:form> <script type="text/javascript"> console.log(document.getElementById('{!$Component.theForm.thePageBlock.StrTestId}').value); </script> </apex:page>
everything works perfectly fine.... but when I create a javascript file into the static resources and I include the file into the visualforce page this stop working and the result is 'Cannot read property 'value of null' which means that getElementById is not finding the element and returns null :(
this is the example is giving me an this error:
<apex:page> <script type="text/javascript" src="{!$Resource.TestZip}/App/testGetElementId.js"></script> <apex:form id="theForm"> <apex:pageblock id="thePageBlock" title="pageBlock"> <apex:inputHidden id="StrTestId" value="{!Test__c.Id}"/> </apex:pageblock> </apex:form> </apex:page>
Somebody have any idea why this is happening....?
Thank you!
Fran.