+ Start a Discussion

Issue with getting element using ElementId

I am trying below code to get the element using elementId but alert message is showing null value. Can anyone please suggest why it is behaving like this :

<apex:page standardController="Account">
  <apex:form >
      <apex:inputField value="{!Account.name}" id="accName"/>
      <apex:commandButton value="Test" onclick="testFunction(); return false;"/>
  function testFunction(){
Best Answer chosen by sharma_ffdc
In this case your inputField is nested in a form tag.
Try giving an ID to the form tag as well and access your component like:

Hope this helps.

Satish Kumar