关闭

用javaScript写了两个简单网页,留着以后参考(之一)

1224人阅读 评论(0) 收藏 举报

<HTML><HEAD><TITLE>孙一飞的作业</TITLE></HEAD>
<SCRIPT>
function GetObjID(ObjName)
{
  for (var ObjID=0; ObjID < form1.elements.length; ObjID++)
    if ( window.form1.elements[ObjID].name == ObjName )
    {  return(ObjID);
       break;
    }
  return(-1);
}
function SelectProvince(form)
{
  var num,n, i, m;
        num= GetObjID('Province');
      
        m = document.form1.elements[num].selectedIndex-1;
        n = document.form1.elements[num + 1].length;
        for(i = n - 1; i >= 0; i--)
                document.form1.elements[num + 1].options[i] = null;

        if (m>=0) {
        for(i = 0; i < city_show[m].length; i++){
                NewOptionName = new Option(city_show[m][i], city_value[m][i]);
                document.form1.elements[num + 1].options[i] = NewOptionName;
        }
        document.form1.elements[num + 1].options[0].selected = true;
        }
 
}

</SCRIPT>


<script>

  var province_show = new Array();
  var province_value = new Array();
  var city_show = new Array();
  var city_value = new Array();
  var funtype;
//Modified by Ryan Gao 2006-03-30 16:01:09
province_show[0] = '山西';
province_value[0] = '2400';
city_show[0] = new Array();
city_value[0] = new Array();
city_show[0][0] = '太原';
city_value[0][0] = '2400';
city_show[0][1] = '大同';
city_value[0][1] = '2401';
city_show[0][2] = '平遥';
city_value[0][2] = '2402';
city_show[0][3] = '长治';
city_value[0][3] = '2403';
province_show[1] = '湖北';
province_value[1] = '0100';
city_show[1] = new Array();
city_value[1] = new Array();
city_show[1][0] = '武汉';
city_value[1][0] = '0100';
city_show[1][1] = '荆州';
city_value[1][1] = '0101';
city_show[1][2] = '潜江';
city_value[1][2] = '0102';
city_show[1][3] = '襄樊';
city_value[1][3] = '0103';
city_show[1][4] = '黄石';
city_value[1][4] = '0104';
province_show[2] = '广东';
province_value[2] = '0200';
city_show[2] = new Array();
city_value[2] = new Array();
city_show[2][0] = '广州';
city_value[2][0] = '0200';
city_show[2][1] = '珠海';
city_value[2][1] = '0201';
city_show[2][2] = '深圳';
city_value[2][2] = '0202';
city_show[2][3] = '中山';
city_value[2][3] = '0203';
city_show[2][4] = '潮州';
city_value[2][4] = '0204';
province_show[3] = '福建';
province_value[3] = '0300';
city_show[3] = new Array();
city_value[3] = new Array();
city_show[3][0] = '厦门';
city_value[3][0] = '0300';
city_show[3][1] = '福州';
city_value[3][1] = '0301';
city_show[3][2] = '莆田';
city_value[3][2] = '0302';
city_show[3][3] = '泉州';
city_value[3][3] = '0303';
city_show[3][4] = '漳州';
city_value[3][4] = '0304';
</script>

<form name = form1 method=post target=_blank>
<table name=table1 border=0 align=center cellSpacing=0 cellpadding=3 width=560>
<tr><TD align=center valign=top width=60><b>省</b></TD>

<TD align=center valign=top width=60><b>城市</b></TD></tr>

         <tr>   <TD width=40% align=right>
              <SELECT NAME=Province style="width:250" size=1 onchange=SelectProvince(this);>
             
<option selected value="0000">请选择省份</option>
<OPTION VALUE="0100">山西</OPTION>
<OPTION VALUE="0100">湖北</OPTION>
<OPTION VALUE="0200">广东</OPTION>
<OPTION VALUE="0300">福建</OPTION>
           
</SELECT>

            </TD>

<TD width=40%>
              <SELECT NAME=City style="width:250" size=1>
                        </SELECT>

            </TD>
 </tr>

</TABLE>
</form>
</BODY>
</HTML>

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:90151次
    • 积分:1025
    • 等级:
    • 排名:千里之外
    • 原创:13篇
    • 转载:33篇
    • 译文:0篇
    • 评论:6条
    最新评论