【发布时间】:2021-05-11 13:38:33
【问题描述】:
在 javascript 中填充表单的最快“性能”方式是什么。
我有这个和它的工作,但我在想有没有更好或更快的方法来做到这一点?
async function PopulateUpdateForm(formID)
{
var currentForm = document.getElementById(formID); // Get the form
var resPrommise = await GetUserData(); // Get responce
// Populate the Form
await resPrommise.json().then(content => // Get the response content
{
if (content != null)
{
currentForm['email'].value = content['email'];
currentForm['firstname'].value = content['firstname'];
currentForm['lastname'].value = content['lastname'];
if (content['age'] != 0)
{
currentForm['age'].value = content['age'];
}
currentForm['phonenumber'].value = content['phonenumber'];
}
});
}
【问题讨论】:
标签: javascript forms input get