首页 > 解决方案 > 使用 JavaScript 代码自动填写(网站表单)和网络发布

问题描述

我有这个网页(http://reg.nid-moi.gov.iq/registersubmit),它包含一个表单,我想根据javascript代码中的以下函数参数通过发布函数来自动填写表单的数据页面源代码如下: Webpage Sourcecode Script : 网页源代码脚本

在此处输入图像描述

标签: javascript

解决方案


有不同的方法可以做到这一点。

<script>
// if you want to fill form on button click
function setInitailFormData(){
//getting the element you want to fill
 var inputName = document.getElementsById('inputName');
//setting up the value
 inputName.value = "Gohan"
}
//if you want to fill on component mount
window.onload = function setInitailFormData(){
//getting the element you want to fill
 var inputName = document.getElementsById('inputName');
//setting up the value
 inputName.value = "Gohan"
}
</script>

推荐阅读