• 将提交按钮变成链接


    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>Example:Submit buttons to links</title>
      <style type="text/css"></style>
      <script type="text/javascript" src="submitToLinks.js"></script>
    </head>
    <body>
      <form action="nogo.php" method="post">
      <p>
       <label for="Name">Name:</label>
       <input type="text" id="Name" name="Name"/>
       <input type="submit" value="send"/>
      </p>
      <p>
       <label for="Email">Email:</label>
       <input type="text" id="Email" name="Email"/>
       <input type="submit" value="check"/>
      </p>
      </form>
    </body>
    </html>

    submitToLinks.js

    function submitToLinks()
    {
        if(!document.getElementById||!document.createTextNode){return;}
        var inputs,i,newLink,newText;
        inputs=document.getElementsByTagName('input');
        for(i=0;i<inputs.length;i++)
        {
            if(inputs[i].getAttribute('type').toLowerCase()!='submit')
            {continue;i++}
            newLink=document.createElement('a');
            newText=document.createTextNode(inputs[i].getAttribute('value'));
            newLink.appendChild(newText);
            newLink.setAttribute('href','javascript:document.forms[0].submit()');
            inputs[i].parentNode.replaceChild(newLink,inputs[i]);
            //if(i<inputs.length){i--};
        }
    }
    window.onload=submitToLinks;

    image

    image

  • 相关阅读:
    Prometheus环境搭建系列(三):监控redis服务器(redis_exporter)
    Java诊断神器:Arthas常用功能
    sql优化练习
    navicat:[Err] 1055
    Prometheus环境搭建系列(二):监控mysql服务器(mysqld_exporter)
    【笔试必备】常见sql笔试题
    将博客搬至CSDN
    springboot假死、连接泄露
    测试字符串
    阿里云初次使用教程
  • 原文地址:https://www.cnblogs.com/vonk/p/3979517.html
Copyright © 2020-2023  润新知