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)
{var song=entry.value
 alert("checking whether"+song+"is a beatles tune...")}
</script><body>
<form onSubmit="return false">
choose your favorite beatle:
<input type="radio" name="Beatles" value="john lennon" checked>john
<input type="radio" name="Beatles" value="15525skj">paul
<input type="radio" name="Beatles" value="sdfoop">george harriden
<input type="radio" name="Beatles" value="ringsi">sloompp<p>
Enter the name of your favorite Beatles song:<BR>
<INPUT type="text" name="song" value="element rigby"
onChange="verifySong(this)"><p>
<input type="button" name="process" value="process request..."
onClick="processData(this.form)">
</form>
</body>
请问大家,这段代码实现的是什么功能,this与this.form都代表什么,它们都什么区别?它们有没有其它的含义?

解决方案 »

  1.   

    这段代码实现的功能是:
    1、点击按扭“process request...”,提交数据.
    2、得到单选框(Radio)的选中值
    3、改变文本框值时,弹出警告显示
    ...this: 当前控件,例:<input onClick="doTest(this)">,该this是指<input>.
    this.form: 当前范围内的<Form>,例:<Form><input onClick="doTest(this.form)"></Form>,该this.form是指<Form>
      

  2.   

    超级大笨狼,灌水专用脚本:
     <SCRIPT LANGUAGE="JavaScript">
      Draw_Triangle(40);
      Draw_Line(40);
    function Draw_Triangle(line)
    {
    var chars="";
    for(i=1;i<=line;i++)
    {
    var blank="";
    var star="";
    for(j=0;j<i;j++)
    {
    star +="*&nbsp;" ;

    for(k=0;k<(line-i);k++)
    {
    blank +="&nbsp";  

    chars+=blank + star + "<br/>";

    }
    document.write(chars);
    }function Draw_Line(line)
    {
    var chars="";
    for(i=1;i<=line;i++)
    {
    var blank="";
    var star="";
    for(j=0;j<line/2;j++)
    {
    star +="*&nbsp;" ;

    for(k=0;k<line/2;k++)
    {
    blank +="&nbsp";  

    chars+=blank + star + "<br/>";

    }
    document.write(chars);
    }
     </SCRIPT>
                                           * 
                                          * * 
                                         * * * 
                                        * * * * 
                                       * * * * * 
                                      * * * * * * 
                                     * * * * * * * 
                                    * * * * * * * * 
                                   * * * * * * * * * 
                                  * * * * * * * * * * 
                                 * * * * * * * * * * * 
                                * * * * * * * * * * * * 
                               * * * * * * * * * * * * * 
                              * * * * * * * * * * * * * * 
                             * * * * * * * * * * * * * * * 
                            * * * * * * * * * * * * * * * * 
                           * * * * * * * * * * * * * * * * * 
                          * * * * * * * * * * * * * * * * * * 
                         * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                       * * * * * * * * * * * * * * * * * * * * * 
                      * * * * * * * * * * * * * * * * * * * * * * 
                     * * * * * * * * * * * * * * * * * * * * * * * 
                    * * * * * * * * * * * * * * * * * * * * * * * * 
                   * * * * * * * * * * * * * * * * * * * * * * * * * 
                  * * * * * * * * * * * * * * * * * * * * * * * * * * 
                 * * * * * * * * * * * * * * * * * * * * * * * * * * * 
                * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
               * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
              * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
             * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
           * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
          * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
         * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
        * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
       * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
      * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
                        * * * * * * * * * * * * * * * * * * * * 
      

  3.   

    <SCRIPT LANGUAGE="JavaScript">
      Draw_Triangle(40);
      Draw_Line(40);
    function Draw_Triangle(line)
    {
    var chars="";
    for(i=1;i<=line;i++)
    {
    var blank="";
    var star="";
    for(j=0;j<i;j++)
    {
    star +="*&nbsp;" ;

    for(k=0;k<(line-i);k++)
    {
    blank +="&nbsp";  

    chars+=blank + star + "<br/>";}
    document.write(chars);
    }function Draw_Line(line)
    {
    var chars="";
    for(i=1;i<=line;i++)
    {
    var blank="";
    var star="";
    for(j=0;j<line/2;j++)
    {
    star +="*&nbsp;" ;

    for(k=0;k<line/2;k++)
    {
    blank +="&nbsp";  

    chars+=blank + star + "<br/>";}
    document.write(chars);
    }
     </SCRIPT>