zoukankan      html  css  js  c++  java
  • javascript自动填写表单小技巧

    javascript自动填写表单小技巧

    在平时开发过程中,或者在访问某些站点,经常要频繁地填写一大堆表单时,我们可以利用javascript,写一段脚本,预先把要填的信息准备好,然后模拟点击按钮的动作,自动提交表单,轻松且高效。

    步骤
    1. 找到页面中对应的form,把form中所需的html控件列出来,如

    <form name="customersForm" id="myform" method="POST" action="insert.php">
        <b> 姓 : </b> <input type="text" name="thisFnameField" size="20" value="">
        <b> 名 : </b> <input type="text" name="thisLnameField" size="20" value="">
        <b> 公司 : </b> <input type="text" name="thisCompanyField" size="20" value=""> 
        <b> 地址 : </b> <input type="text" name="thisAddressField" size="20" value="">
    /form>

    2.编写js代码

    javascript:customersForm.thisFnameField.value = "张";customersForm.thisLnameField.value = "三";customersForm.thisCompanyField.value = "公司";customersForm.thisAddressField.value = "中国";customersForm.submit.focus();

    3.第三步最重要,因为前2步稍微有点js知识的人都会写这么简单的代码。接下来就是利用浏览器的收藏夹(书签)功能寄存js代码。
    以chrome为例,在书签上点击右键————> 添加网页,名称填【自动填表】,网址填【上面那段js代码】,然后保存即可。

    4.测试一下。
    在浏览器中打开对应的页面,然后点击书签栏中的【自动填表】,你就会惊奇的发现表格已经填好了。

  • 相关阅读:
    loj1201(最大独立集)
    hdu4185+poj3020(最大匹配+最小边覆盖)
    【Leetcode】3Sum Closest
    【Leetcode】3Sum
    【Leetcode】Two Sum
    【Leetcode】Longest Consecutive Sequence
    【Leetcode】Median of Two Sorted Arrays
    【Leetcode】Search in Rotated Sorted Array II
    【Leetcode】Search in Rotated Sorted Array
    【Leetcode】Remove Duplicates from Sorted Array II
  • 原文地址:https://www.cnblogs.com/fanyong/p/3344364.html
Copyright © 2011-2022 走看看