Javascript uncaught error

Support forumJavascript uncaught error
Vivek asked 7 years ago
Hey. I am trying to add the values of custom fields name and email via javascript. In this endeavour, I am doing this thing -> //document.getElementsByName("name")[0].value = userName; When I was using the plugin as php short code in my file it was displaying the values in these labels. But when I am using it on a separate page I am getting the error that it cannot set the property value of undefined. Help Please. Been 3 day, tried every sort of thing to make this work, otherwise, I would have to look for some other plugin to do the needful.
1 Answers
Nikola Loncar Staff answered 7 years ago
Hi Vivek, you need to wait for form to be rendered on page. That is the reason why you get that error on separate page. I can add custom call back when it is loaded so you can connect on it and then change the value for field. Also you can do that simply by adding that value to local storage or setting in within url. For example: url?name=test . Best regards, Nikola