form的名字别用form关键字,改成form1什么的,最好有实际意义的form

解决方案 »

  1.   

    <script>
      function f1()
      {
        var v1=document.all.year_from.options[document.all.year_from.selectedIndex].text
        var v2=document.all.year_to.options[document.all.year_to.selectedIndex].text 
        if(v1>v2)
        {
        alert("big");
        }  }
    </script>
    <select id="year_from">
    <option>
    2002</option>
    <option>
    2003</option>
    <option>
    2004</option>
    <option>
    2005</option></select><select id="year_to">
    <option>
    2003</option>
    <option>
    2004</option></select><input type="button" onclick=f1()>