| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1045 人关注过本帖
标题:关于JS中的问题,请指教。斑竹,JS版块人太少,我发这里了
只看楼主 加入收藏
孤星
Rank: 1
等 级:新手上路
帖 子:127
专家分:0
注 册:2004-6-30
收藏
 问题点数:0 回复次数:4 
关于JS中的问题,请指教。斑竹,JS版块人太少,我发这里了

<!--#include file="conn.asp"--> <% '-----------------------取出大类列表 %> <% dim rs1 dim sql1 set rs1=server.CreateObject ("ADODB.RecordSet") sql1="select * from sheng" rs1.open sql1,conn,1,1 %> <% '------------------------结束 %>

<% '==================================================取出行业小类%> <% dim rs2 dim sql2 dim count set rs2=server.createobject("ADODB.RecordSet") sql2 = "select * from city" rs2.open sql2,conn,1,1 %> <script language="JavaScript"> var onecount; onecount=0; subcat = new Array(); <% count = 0 do while not rs2.eof %> subcat[<%=count%>] = new Array("<%= trim(rs2("sort2_name"))%>","<%= trim(rs2("sort_ID"))%>","<%= trim(rs2("sort2_ID"))%>");

<% count = count + 1 rs2.movenext loop rs2.close %> onecount=<%=count%>; function changelocation(locationid) { document.frmorder.city.length = 0; document.frmorder.city.options[document.frmorder.city.length] = new Option("请选择城市", ""); var locationid=locationid; var i; for (i=0;i < onecount; i++) { if (subcat[i][1] == locationid) { document.frmorder.city.options[document.frmorder.city.length] = new Option(subcat[i][0], subcat[i][2]); } }

} </script> <script language="JavaScript"> <!-- function na_select_form (fname, type_name) { document.frmorder[fname].elements[type_name].select() document.frmorder[fname].elements[type_name].focus() } // --> </script> <% '============================================结束 %>

<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%"> <form name='frmorder' action='***' method='post'> <TD>行业类别</TD> <TD colspan="2"> <select name="shengfen" style="WIDTH:100px" onChange="changelocation(document.frmorder.shengfen.options[document.frmorder.shengfen.selectedIndex].value)"> <option selected value="">省份</option> <% do while not rs1.eof %> <option value="<%=trim(rs1("sort_ID"))%>"><%=trim(rs1("sort_name"))%></option> <% rs1.movenext loop rs1.close %> </select> <select name="city" style="WIDTH:100px"> <option selected value="">城市</option> </select> </TD> </TR> </form> </table>

这段JS是实现下拉彩单二级连动。shengfen city frmorder 分别是字段名 字段名 和表名

搜索更多相关主题的帖子: 版块 斑竹 指教 
2004-12-06 09:28
孤星
Rank: 1
等 级:新手上路
帖 子:127
专家分:0
注 册:2004-6-30
收藏
得分:0 

我把上面的脚本嵌到了主页面

<!--#include file="conn.asp"--> <HTML> <HEAD> <title>会议订购</title> <link href="css/text.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"></HEAD> <BODY leftmargin="0" topmargin="0" > <body background="../images/bg1.gif"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width='100%' height="18">&nbsp; </td> </tr> </table> <table width="775" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="15" bgcolor="#999999"></td> </tr> </table>

<table width="775" cellpadding="0" cellspacing="0" style="border:1px solid #C7AA83"> <tr> <td valign="top" align="center"><BR> <table width="90%" cellpadding="5" cellspacing="0"> <tr> <td><BR> <B> <span class="hotel">填写预订单《会议预定》</span></B> <form name="frmOrder" method="post" action="savehuiyi.asp" ><!-- onsubmit="return CheckForm()"--> <!-- <form name="frmOrder" method="post" action="addHotelOrder.asp?ID=&roomID=" onsubmit="return CheckForm()">--> <table width="100%" cellpadding="2" cellspacing="0" style="border:1px solid #C7AA83"> <tr bgcolor="#CCCCCC"> <td align="center" height="26" colspan="4"><B>请填写入住信息</B>(*为必须填写项)</td> </tr> <tr bgcolor="#CCCCCC"> <td align="center" height="1" colspan="4" bgcolor="#990704"></td> </tr> <tr> <td height="6" colspan="4"></td> </tr> <% dim rs1 dim sql1 set rs1=server.CreateObject ("ADODB.RecordSet") sql1="select * from sheng" rs1.open sql1,conn,1,1 %> <% '------------------------结束 %>

<% '==================================================取出行业小类%> <% dim rs2 dim sql2 dim count set rs2=server.createobject("ADODB.RecordSet") sql2 = "select * from city" rs2.open sql2,conn,1,1 %> <script language="JavaScript"> var onecount; onecount=0; subcat = new Array(); <% count = 0 do while not rs2.eof %> subcat[<%=count%>] = new Array("<%= trim(rs2("sort2_name"))%>","<%= trim(rs2("sort_ID"))%>","<%= trim(rs2("sort2_ID"))%>");

<% count = count + 1 rs2.movenext loop rs2.close %> onecount=<%=count%>; function changelocation(locationid) { document.frmorder.city.length = 0; document.frmorder.city.options[document.frmorder.city.length] = new Option("请选择城市", ""); var locationid=locationid; var i; for (i=0;i < onecount; i++) { if (subcat[i][1] == locationid) { document.frmorder.city.options[document.frmorder.city.length] = new Option(subcat[i][0], subcat[i][2]); } }

} </script> <script language="JavaScript"> <!-- function na_select_form (fname, type_name) { document.frmorder[fname].elements[type_name].select() document.frmorder[fname].elements[type_name].focus() } // --> </script> <% '============================================结束 %>

<tr height="26"> <td align="right" width="100">所在城市&nbsp;</td> <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td> <table border="0" width="98%" cellpadding="1" cellspacing=0 align="center"> <tr> <td height="-2" colspan="2">选择省份&nbsp;&nbsp; <select name="shengfen" style="WIDTH:100px" onChange="changelocation(document.frmorder.shengfen.options[document.frmorder.shengfen.selectedIndex].value)"> <option selected value="">省份</option> <% do while not rs1.eof %> <option value="<%=trim(rs1("sort_ID"))%>"><%=trim(rs1("sort_name"))%></option> <% rs1.movenext loop rs1.close %> </select> </td> </tr> <tr> <td height="20" colspan="2">选择城市&nbsp;&nbsp; <select name="city" style="WIDTH:100px"> <option selected value="">城市</option> </select> </td> </tr> <td width="19%"></td> </tr> </table></td> </tr> </table></td> <td width="130" align="right">星级选择&nbsp;</td> <td><select name="star" class="login" style="width:110px;" width="100%"> <option value="0">星级</option> <option value="5">五星</option> <option value="准五星">准五星</option> <option value="4">四星</option> <option value="准四星">准四星</option> <option value="3">三星</option> <option value="准三星">准三星</option> <option value="2">二星</option> <option value="准二星">准二星</option> </select></td> </tr> <tr height="26"> <td align="right">酒店名称</td> <td colspan="3"><input name="h_Name" type="text" class="login" id="hotelName" size="30" width="100%"> &lt;如不填写本公司将推荐酒店&gt;</td> </tr> <tr height="26"> <td align="right">会员卡号</td> <td><input name="txtAccounts" type="text" class="login" maxlength=16 width="100%"> (无卡号可不填)<font color="#FF0000"><b></b></font></td> <td width="130" align="right">会议人数&nbsp;</td> <td><input name="txtPeopleNO" type="text" class="login" maxlength="4" width="100%"> &nbsp;<font color="#FF0000"><b></b></font></td> </tr> <tr height="26"> <td align="right">负责人</td> <td><INPUT NAME="fuze_name" TYPE="text" class="login" width="100%" > &nbsp;<font color="#FF0000"><B></B></font></td> <td align="right">性别&nbsp;</td> <td> <select name="Sex" class="login" style="font-size:12px;width:152"> <option value="男" selected>先生</option> <option value="女">女士</option> </select> </td> </tr> <tr height="26"> <td align="right" width="100">&nbsp;</td> <td>(根据入住房间数,填写多位客人姓名!)</td> <td align="right" width="130">客人类型&nbsp;</td> <td> <select name="txtCategory" class="login" style="font-size:12px;width:152"> <option value="内宾" selected>内宾</option> <option value="外宾">外宾</option> </select> </td> </tr>

2004-12-06 09:31
孤星
Rank: 1
等 级:新手上路
帖 子:127
专家分:0
注 册:2004-6-30
收藏
得分:0 
<tr height="26"> <td align="right">房间数量&nbsp;</td> <td><INPUT NAME="h_shuliang" TYPE="text" class="login" maxlength="5" width="100%"> &nbsp;<font color="#FF0000"><B>*</B></font></td> <td align="right">房间类型&nbsp;</td> <td> <input name='h_class' type='text' class="login" maxlength='50' width="100%"> </td> </tr> <tr height="26"> <td align="right">住店日期&nbsp;</td>

<td> <!--<INPUT TYPE="text" NAME="txtBeginTime" value="">--> <div align="left"> <font color="#FF0000"><B>*</B></font> </div></td> <td align="right">离店日期&nbsp;</td> <td> <!--<INPUT TYPE="text" NAME="txtEndTime" value="">--> <div align="left"> <font color="#FF0000"><B>*</B></font> </div></td> </tr> <tr height="26"> <td align="right">最早到达时间&nbsp;</td> <td> <select name="h_time" size="1" class="login" style="font-size:12px;width:152"> <option value="7:00:00">7:00</option> <option value="8:00:00" selected>8:00</option> <option value="9:00:00">9:00</option> </select> </td> </tr> <tr height="26"> <td align="right">电话&nbsp;</td> <td> <INPUT NAME="tel" TYPE="text" class="login" maxlength=100> &nbsp;<font color="#FF0000"><B>*</B></font> </td> <td align="right">手机&nbsp;</td> <td><INPUT NAME="phone" TYPE="text" class="login" maxlength=50></td> </tr> <tr height="26"> <td align="right">电子邮件&nbsp;</td> <td><INPUT NAME="email" TYPE="text" class="login" maxlength="80"></td> <td align="right">预订完成确认方式&nbsp;</td> <td> <select name="queren" class="login" style="font-size:12px;width:152"> <!--<option value="不用确认">不用确认</option>--> <option value="电话">电话</option> <option value="手机" selected>手机</option> <!-- <option value="传真">传真</option> <option value="eMail">E-MAIL</option> --> </select> </td> </tr> <tr> <td align="right">付款方式&nbsp;</td> <td colspan="3"> <input type="hidden" name="txtChargeCategory"> <select name="txtChargeCategory1" class="login" style="font-size:12px;width:152"> <option value="现付" selected>现付</option> <option value="挂帐">挂帐</option> </select> 现付为酒店前台支付,挂帐为由我公司收取方式。 <!--<td align="right"></td> <td></td>--> </tr> <tr> <td colspan="4" height="10"></td> </tr> <tr> <td align="right" valign="top">其它要求&nbsp;</td> <td colspan="3" valign="top"> <TEXTAREA NAME="content" COLS="66" ROWS="6" class="login"></TEXTAREA> <BR> <BR> </td> </tr> </table> <BR> <BR> <table width="100%" cellpadding="2" cellspacing="0" style="border:1px solid #C7AA83"> <tr bgcolor="#CCCCCC"> <td align="center" colspan="4" height="26"><B>联系人信息</B> </td> </tr> <td align="center" colspan="4" height="1" bgcolor="#990704"></td> </tr> <tr> <td align="center" colspan="4" height="3"></td> </tr> <tr> <td align="center" colspan="4" height="22"> </td> </tr> <tr> <td align="right">联系人名称&nbsp;</td> <td> <INPUT NAME="l_name" TYPE="text" class="login" value="" maxlength=50> </td> <td align="right">联系电话&nbsp;</td> <td> <INPUT NAME="l_tel" TYPE="text" class="login" value="" maxlength='100'> <td> </tr> <tr> <td align="right">联系传真&nbsp;</td> <td> <INPUT NAME="l_chuan" TYPE="text" class="login" value="" maxlength='100'> </td> <td align="right">联系邮箱&nbsp;</td> <td><INPUT NAME="l_email" TYPE="text" class="login" value="" maxlength="80"> </td> </tr> <tr> <td colspan="4" align="right"> <!--<INPUT TYPE="image" src="images/submit.gif" onclick=" return CheckForm()">--> <input name="submit" type="button" class="greenlogin" value="我要下订单"> &nbsp;&nbsp;&nbsp;&nbsp; <input name="reset" type="reset" class="greenlogin" value="重 填"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="goBack" type="button" class="greenlogin" onclick="javascript:history.back()" value="上一步"> <input type="hidden" name="cert" value="testA"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR> <BR> <input type="hidden" value="" name="txtHotelName"> <hr size="1"> <table width="95%" cellpadding="0" cellspacing="0"> <tr height="22"> <td colspan="2">注&nbsp;&nbsp;意::</td> </tr> </table></td> </tr> </table> <BR> <BR> </form></td> </tr> </table></td> </tr> </table>

<table width="775" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#999999" height="10"></td> </tr> <tr> <td height="4"></td> </tr> </table>

</BODY> </HTML>

第一段JS实现的是下拉二级动态。我已经测试过了,正常。

可是我把他放到第二个,主页面的时候就报错了:

document.frmorder.shengfen为空或不是对象。

大家帮忙看看。

2004-12-06 09:31
孤星
Rank: 1
等 级:新手上路
帖 子:127
专家分:0
注 册:2004-6-30
收藏
得分:0 

我新建了一个TABLE。把JS代码嵌进去,就好了。

搞不明白JS嵌入的时候都要注意那些地方。

2004-12-06 12:20
寒星
Rank: 1
等 级:新手上路
帖 子:455
专家分:0
注 册:2004-6-7
收藏
得分:0 

frmOrder

大小写吧

frmorder


http://www. 版主位置空缺
2004-12-06 12:55
快速回复:关于JS中的问题,请指教。斑竹,JS版块人太少,我发这里了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019779 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved