javascript - 使用 JavaScript 代码自动填写(网站表单)和网络发布
问题描述
我有这个网页(http://reg.nid-moi.gov.iq/registersubmit),它包含一个表单,我想根据javascript代码中的以下函数参数通过发布函数来自动填写表单的数据页面源代码如下: Webpage Sourcecode Script : 网页源代码脚本
解决方案
有不同的方法可以做到这一点。
<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>
推荐阅读
- django - 有没有办法在应用程序构建时显示网页?
- c++ - (Arduino) 有没有办法添加秒表来计算用户使用该程序的时间?
- web-scraping - www.azlyrics.com 的 /robots.txt 中的“/lyricsdb/”指的是什么?
- javascript - 使用用户 ID 更新列字段的 Mysql 语法
- reactjs - 当用户在基于 NextJS 的网站上滚动时调整 #anchor (URL)
- java - 无法自动装配:在 IntelliJ 中找不到“MongoTemplate”类型
- c# - 如何将值传递给另一个程序集中的类的构造函数
- c++ - 编译器如何区分相同的函数参数名称和类成员名称?
- flutter - 在返回最后一个值的列表视图中调用 BlocBuilder
- c# - Moq dotnetfiddle 中的“覆盖方法的安全可访问性必须与被覆盖方法的安全可访问性相匹配”