1

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()
{
 alert('Hi');
  var n1 = document.getElementById("!$Component.frm.verify.verSec.dcNameVerfiy_lkid}");  
  alert('text:'+n1);
  alert('Text'+n1.value);
 var n2 = document.getElementById("{!$Component.frm1.block.poSec.dcName}");
  alert('Text1'+n2);
  n2.value = n1.value;

}

enter image description here

1 Answer 1

2

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

"!$Component.frm.verify.verSec.dcNameVerfiy_lkid}"

should be:

"{!$Component.frm.verify.verSec.dcNameVerfiy_lkid}"

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 .