• Javascript的this例子


    <!--这个程序使用了javascript中的this,this可以减少很多不必要的代码量,并且提高代码的效率-->
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <script language="javascript">
    function processData(form){
    for (var i = 0; i < form.Beatles.length; i++) {
    if (form.Beatles[i].checked) {
    break;
    }
    }
    var beatle = form.Beatles[i].value;
    var song = form.song.value;
    alert("Checking whether"+"   "+ song+"   "+ "features"+"   "+ beatle+"   "+ "...");
    }

    function verifySong(entry){//这里的entry是随便起的也可以叫别的名
    var song = entry.value;
    alert("Checking whether" +"   "+ song+"   " + "is a Beatles tune...");
    }
    </script>
    </head>
    <body>
    <form onSubmit="return false">
    Choose your favorite Beatle:
    <input type="radio" name="Beatles" value="John Lennon" checked/>John  <!--看到这里的checked了吧可以这样太简单了-->
    <input type="radio" name="Beatles" value="Paul McCartney"/>Paul
    <input type="radio" name="Beatles" value="George Harrison"/>George
    <input type="radio" name="Beatles" value="Ringo Starr"/>Ringo
    <p>
    Enter the name of your favorite Beatles song:
    <br>
    <input type="text" name="song" value="Eleanor Rigby" onChange="verifySong(this)"/>
    <p>
    <input type="button" name="process" value="Process Request..." onClick="processData(this.form)"/>
    <!--因为这个按钮是要提交表单的,直接将form传到指定的函数中-->
    </form>
    </body>
    </html>

  • 相关阅读:
    SQLSERVER查询数据库文件大小
    SQLSERVER 检查内容
    20万DBA都在关注的12个问题 [转载]
    oswbb工具分析主机性能
    Suspending MMON slave action kewrmapsa_ for 82800 seconds
    一次direct path read 故障处理
    Auto Optimizer Stats Collection in 12c
    ORACLE 动态注册和静态注册的区别(转)
    记一次cursor pin s wait on X的处理
    树莓派3b的raspberrypi系统安装pip
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/1775783.html
Copyright © 2020-2023  润新知