I have created a Vf page.In that VF page I have look up field for Account look up.My requirement is to get the look up id and pass the id to text box.I have tried the below code but it is not working im getting null value(text:null) , im seen in lookup id value in Inspect Element.Can anyone help me to solve this issue?

function ValuePass()
  var n1 = document.getElementById("!$Component.frm.verify.verSec.dcNameVerfiy_lkid}");  
 var n2 = document.getElementById("{!$Component.frm1.block.poSec.dcName}");
  n2.value = n1.value;


enter image description here

1 Answer 1


You have a missing { in both your expressions e.g.:


should be:


I suggest you use your browser's "View Page Source" feature to check what ID value has been generated by the server.

As you have given most elements an ID, if you also gave the apex:page an ID of "p" you could use the ID values directly:

var n1 = document.getElementById("p:frm:verify:verSec:dcNameVerfiy_lkid");

Note the colons here not the dots.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .