Ranbijay Ranbijay - 11 days ago 7
HTML Question

Not able to figure out getElementById()

I am trying to print a text in html page through js .
My code is

var nameOfCreator = "XYZ";
var scriptcode="document.getElementById('billto_first_name').value='ABC' ";
frmB.Browser0422f79dce36f4c.evaluateJavaScript(scriptcode);
frmB.Browser0422f79dce36f4c.evaluateJavaScript("document.getElementById('billto_first_name').value= nameOfCreator ");`


The expected output is XYZ but getting ABC.Can anyone help.

Thanks in advance.

Answer

try this

frmB.Browser0422f79dce36f4c.evaluateJavaScript("document.getElementById('billto_first_name').value= '" + nameOfCreator + "'");