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
Prakash@SFDCPrakash@SFDC 

document.getElementById not working

I am trying to access the radio button value in JScript using 

 

var h = document.getElementById("{!$Component.wizpage.wizardForm.agmtInfo.ContractDetailsSec.whoSignFirstSection.whoSignFirstId}").value;
alert(h);

 

I am getting undefined . What might be the issue ? Please give some idea .

 

1. i am using proper id values while accessing .

2. There is no JavaScript error .

 

Many Thanks in Advance

Prakash

Prafull G.Prafull G.
Just before your above script, Could you please check if the Id is correct using javascript alert?
i.e.
alert("{!$Component.wizpage.wizardForm.agmtInfo.ContractDetailsSec.whoSignFirstSection.whoSignFirstId}");
Sridhar BonagiriSridhar Bonagiri

Hi,

 

I think the Id of the component which you are referring might have changed , If there are any page block , page block sections their ID's also will be prefixed to the component which you are referring. Please check the Id of the component in the 'View Page Source' section.

 

Regards,

Sridhar Bonagiri

oaklandoakland

Well the DOM might not have fully rendered when your JavaScript executes.

You can try:

 

1. Putting the JavaScript at the bottom of the page

 

Like this:

 

 

<script type="text/javascript">
 if (document.getElementById('ROTATEME')) {
 swapImage(document.getElementById('ROTATEME'), 'HOME');
 }
 </script>
</body>
</html>

 

 OR

2. Use a what ever solution works for you when you google "Javascript for when dom is ready"