I have a VF Page where I wanted to get the record details when I check the checkbox. So I am trying to achieve this through javascript.
Here is the call the Javascript on click of 'Ok' button.
<apex:pageBlockButtons location="bottom">
<div align="Right" draggable="false">
<apex:commandButton value="Ok" id="selectEmp" onClick="selectAllEmployees();">
</apex:commandButton>
<apex:commandButton value="Cancel" onclick="window.top.close()" />
</div>
</apex:pageBlockButtons>
function selectAllEmployees() {
var selectedbox = document.getElementsByTagName('input');
var checkboxesChecked = [];
var selectedNames = [];
for(var i=0; i<selectedbox.length; i++) {
if(selectedbox[i].type == "checkbox") {
if(selectedbox[i].checked){
alert('inside if'+selectedbox[i].checked); //It is retriving value as true on this alert
var fname = document.getElementsById('{!$Component.employeeLookupPage.EmployeeForm.employeeList.employeeBlock.tblResults.fname}').value;
alert(fname); //I am not able to get the value of First name here.
selectedNames.push(fname);
}
}
}
}