下拉菜单的Onchange的问题

shuichong 2003-08-20 03:44:56
<tr>
<td width="16%" class=Forumrow>资产类型</td>
<td width="34%" class=Forumrow>
<select name=assettype onchange=....>
<option value="1" selected>房地产</option>
<option value="2">摊位(店铺)</option>
<option value="3">车辆</option>
<option value="4">机器设备</option>
<option value="5">其他</option>
</select>


</td>
<td width="16%" class=Forumrow>名称</td>
<td width="34%" class=Forumrow>
<INPUT maxLength=250 size=25 name=assetname>
</td>
</tr>
<tr>
<td width="16%" class=Forumrow>状况</td>
<td width="34%" class=Forumrow>
<INPUT id=cardid maxLength=250 size=25 name=assetStatus></td>
<td width="16%" class=Forumrow>地址</td>
<td width="34%" class=Forumrow>
<input type=text maxlength=100 size=25 name=AssetAddress>
</td>
</tr>



<tr>
<td width="16%" class=Forumrow>建筑面积</td>
<td width="34%" class=Forumrow>

<input type=text name=buildarea>㎡
</td>
<td width="16%" class=Forumrow>占地面积</td>
<td width="34%" class=Forumrow>

<input type=text name=holdarea>㎡

</tr>
<tr>
<td width="16%" class=Forumrow>所有权证号码</td>
<td width="34%" class=Forumrow>
<INPUT maxLength=250 size=25 name=groundid></td>
<td width="16%" class=Forumrow>使用权证号码</td>
<td width="34%" class=Forumrow>
<INPUT maxLength=250 size=25 name=houseid></td>
</tr>
<tr>
<td width="16%" class=Forumrow>他项权证号码</td>
<td width="34%" class=Forumrow>
<INPUT maxLength=250 size=25 name=otherid></td>
<td width="16%" class=Forumrow>评估价值</td>
<td width="34%" class=Forumrow>
<INPUT maxLength=250 size=24 name=pvalue>万元
</td>
</tr>
上面是在选择房地产的时候需要显示的表单和标签
如果在onchange后选择如车辆之后,变成车辆有关的内容,如何写啊?
...全文
63 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
henhuaqi 2003-08-20
  • 打赏
  • 举报
回复
看看下面的例子,如果要求初始状态都为全部,且不管第1个list选择哪一项,则第2,3两个list的初始值都是全部,那怎么改??
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var arrItems1 = new Array();
var arrItemsGrp1 = new Array();

arrItems1[3] = "Truck";
arrItemsGrp1[3] = 1;
arrItems1[4] = "Train";
arrItemsGrp1[4] = 1;
arrItems1[5] = "Car";
arrItemsGrp1[5] = 1;

arrItems1[6] = "Boat";
arrItemsGrp1[6] = 2;
arrItems1[7] = "Submarine";
arrItemsGrp1[7] = 2;

arrItems1[0] = "Planes";
arrItemsGrp1[0] = 3;
arrItems1[1] = "Ultralight";
arrItemsGrp1[1] = 3;
arrItems1[2] = "Glider";
arrItemsGrp1[2] = 3;

var arrItems2 = new Array();
var arrItemsGrp2 = new Array();

arrItems2[21] = "747";
arrItemsGrp2[21] = 0
arrItems2[22] = "Cessna";
arrItemsGrp2[22] = 0

arrItems2[31] = "Kolb Flyer";
arrItemsGrp2[31] = 1
arrItems2[34] = "Kitfox";
arrItemsGrp2[34] = 1

arrItems2[35] = "Schwietzer Glider";
arrItemsGrp2[35] = 2

arrItems2[99] = "Chevy Malibu";
arrItemsGrp2[99] = 5
arrItems2[100] = "Lincoln LS";
arrItemsGrp2[100] = 5
arrItems2[57] = "BMW Z3";
arrItemsGrp2[57] = 5

arrItems2[101] = "F-150";
arrItemsGrp2[101] = 3
arrItems2[102] = "Tahoe";
arrItemsGrp2[102] = 3

arrItems2[103] = "Freight Train";
arrItemsGrp2[103] = 4
arrItems2[104] = "Passenger Train";
arrItemsGrp2[104] = 4

arrItems2[105] = "Oil Tanker";
arrItemsGrp2[105] = 6
arrItems2[106] = "Fishing Boat";
arrItemsGrp2[106] = 6

arrItems2[200] = "Los Angelas Class";
arrItemsGrp2[200] = 7
arrItems2[201] = "Kilo Class";
arrItemsGrp2[201] = 7
arrItems2[203] = "Seawolf Class";
arrItemsGrp2[203] = 7

function selectChange(control, controlToPopulate, ItemArray, GroupArray)
{
var myEle ;
var x ;
// Empty the second drop down box of any choices
for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
if (control.name == "firstChoice") {
// Empty the third drop down box of any choices
for (var q=myChoices.thirdChoice.options.length;q>=0;q--) myChoices.thirdChoice.options[q] = null;
}
// ADD Default Choice - in case there are no values
myEle = document.createElement("option") ;
myEle.value = 0 ;
myEle.text = "全部" ;
controlToPopulate.add(myEle) ;
// Now loop through the array of individual items
// Any containing the same child id are added to
// the second dropdown box
for ( x = 0 ; x < ItemArray.length ; x++ )
{
if ( GroupArray[x] == control.value )
{
myEle = document.createElement("option") ;
myEle.value = x ;
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
}
// End -->
</script>
<form name=myChoices>
<table align="center">
<tr>
<td>
<SELECT id=firstChoice name=firstChoice onchange="selectChange(this, myChoices.secondChoice, arrItems1, arrItemsGrp1);">
<option value='' SELECTED>全部</option>
<option value=1>Land</option>
<option value=2>Sea</option>
<option value=3>Air</option>
</SELECT>
</TD><TD>
<SELECT id=secondChoice name=secondChoice onchange="selectChange(this, myChoices.thirdChoice, arrItems2, arrItemsGrp2);">
<option value='' SELECTED>全部</option>

</SELECT>
<SELECT id=thirdChoice name=thirdChoice>
<option value='' SELECTED>全部</option>

</SELECT>
</TD>
</TR>
</TABLE>
</form>

rongwenfeng 2003-08-20
  • 打赏
  • 举报
回复
也可以使用锚<a id=""></a>
如果要具体例子可以说
ky99xing 2003-08-20
  • 打赏
  • 举报
回复
先清空原来的,再添加
类似的例子:
http://www.baron.com.cn/javascript/cookie/0705cook3.htm
http://www.baron.com.cn/javascript/skill/20020109skill2.htm
http://www.baron.com.cn/javascript/dao/20020722dao2.htm
完全用asp实现二级下拉框联动,asp实现二级菜单联动。文件内附详细源码, 部分源码预览: