If you want to copy the value (text) of a lookup field to a text box, you can use this code below with a lookup field called – new_lookupid and a Text field (nvarchar or ntext) called – new_textfield

var lookup = crmForm.all.new_lookupid.DataValue;
if (lookup[0] !=null)
{
var theText = lookup[0].name;
}
crmForm.all.new_textfield.DataValue = (theText);
crmForm.all.new_textfield.ForceSubmit = true;

Incoming search terms