电信主站 网通分站
购买流程 付款方式 常见问题 在线提问 续租服务 购物车
用户名: 密 码: 忘记密码?
首 页
域名注册
虚拟主机
双线主机
服务器租用
VPS主机
企业邮局
代理专区
客服中心
虚拟主机行业资讯 虚拟主机评测对比 互联网最新动态 技术学院 站长资讯 在线教程 网站运营
搜索优化 服务器 网络编程 图形图象 站长之家 网页制作 操作系统
冲浪宝典 软件教学 视频通信 办公软件 邮件系统 网络安全 认证考试
您当前位置:西部数码->资讯中心-> 在线教程-> CGI
客户端CGI——结合javascript、dhtml实现bbs的backoffice(一)。
作者:网友供稿 点击:29
  西部数码-全国虚拟主机10强!20余项虚拟主机管理功能,全国领先!第6代双线路虚拟主机,南北访问畅通无阻!虚拟主机可在线rar解压,自动数据恢复设置虚拟目录等.虚拟主机免费赠送访问统计,企业邮局.Cn域名注册10元/年,自助建站480元起,免费试用7天,满意再付款!P4主机租用799元/月.月付免压金!
文章页数:[1] 
         客户端cgi——结合javascript、dhtml实现bbs的backoffice(只与服务器交互一次)。
    最近见到很多朋友问有关对form元素的操作问题,下面把我写的一个bbs的backoffice部分帖出来给大家。这个程序实现了对bbs中栏目及其下属论坛的增、删、改名、排序、移动、修改属性等等操作,而只与服务器交互一次,其中用到的表单元素有text , button, submit,select , textarea等,如果你能够全部理解这些代码,那么不敢说你精通javascript和dhtml(我就不敢),最起码可以说你会了。
    因为是草稿,所以未进行程序优化及界面处理,实际上你如果结合css可以把它做得象一个windows程序而不象html页面。另外一条因为我是用ie5来测试的,所以其中一些写法不是很规范,如引用form名时前面没加document , 函数没有返回值等,这些在nescape里都是不允许的,如果你要在nescape里用,请自己把语法规范了。
    由于源代码很长(30000多字节),我将分为几个部分来讲,你把几部分中的代码合在一起存为一个html文件就可以直接运行了。首先需要从数据库中取出记录放到前台javascript数组中,因为着重点是放在前台,所以这里的asp我就不列出来了,只把它生成的html列出来,它的目的是生成数组及初始页面。这部分代码中牵涉到一个生成javascript二维数组的技巧,请大家仔细看一下,这是整个程序的关键所在。下面这段程序生成两个数组,一个是acategory,代表bbs大的栏目,共有四个;另一个是aforum,代表同栏目相关联的论坛。整个程序的操作实际上就是围绕着两个数组来实现的,同这两个数组相关联的是表单frmmanager的两个select :selcategory和selforum。


<script language=javascript>

   //版块数组的构造函数
   function makecategory(categoryid , categoryname , ordernum)
     {
       this.categoryid   = categoryid ;
       this.categoryname = categoryname ;
       this.ordernum     = ordernum ;
       return this ;
     }

   //论坛数组的构造函数
   function makeforum(categoryid , categoryname , ordernum , rootcategoryid , description , masterid)
     {
       this.categoryid     = categoryid ;
       this.categoryname   = categoryname ;
       this.ordernum       = ordernum ;
       this.rootcategoryid = rootcategoryid ;
       this.description    = description ;
       this.masterid       = masterid ;
       return this ;
     }

   //建立版块数组并赋值
  var acategory = new array() ;
  acategory[0] = new makecategory(1 , 技术交流 ,1) ;
  acategory[1] = new makecategory(2 , 项目管理 ,2) ;
  acategory[2] = new makecategory(3 , 内部公告 ,3) ;
  acategory[3] = new makecategory(4 , 海阔天空 ,4) ;

   //建立论坛数组并赋值
  var aforum = new array() ;
  aforum[0] = new makeforum(5 , asp&database ,1 ,1 ,asp, access,pb, sql.oralce,etc. ,1);
  aforum[1] = new makeforum(6 , design world ,2 ,1 ,photoshop,dreamweaver,flash, 3dmax,etc.,2);
  aforum[2] = new makeforum(7 , design world ,3 ,1 ,photoshop,dreamweaver,flash, 3dmax,etc.,2);
  aforum[3] = new makeforum(8 , program language ,4 ,1 ,java, html/dhtml/xml, c/c++, php/jsp, vbscript/javascript, etc.,1);
  aforum[4] = new makeforum(9 , system administration ,5 ,1 ,windows9x/nt/2000, unix, linux , etc.,2);
  aforum[5] = new makeforum(10 , network security ,6 ,1 ,tcp/ip, socket, hacker, firewall, proxy, etc.,1);
  aforum[6] = new makeforum(11 , new idea ,7 ,1 ,welcome all creative, innovative and anything different .,1);
  aforum[7] = new makeforum(12 , 4biz电子商务搜索引擎门户项目 ,1 ,2 ,e-commerce search engine portal.,2);
  aforum[8] = new makeforum(13 , poker town ,2 ,2 ,our first online game.,1);
  aforum[9] = new makeforum(14 , vertigine ,3 ,2 ,powerful vertical search engine.,2);
  aforum[10] = new makeforum(15 , easycase ,4 ,2 ,easycase-new modeling tool.,1);
  aforum[11] = new makeforum(16 , 日常管理 ,1 ,3 ,daily grind.,2);
  aforum[12] = new makeforum(17 , 临时通知 ,2 ,3 ,temporary notice.,1);
  aforum[13] = new makeforum(18 , 会议安排 ,3 ,3 ,meeting schedule.,2);
  aforum[14] = new makeforum(19 , 有感而发 ,4 ,4 ,just say it.,1);
  aforum[15] = new makeforum(20 , 似水流年 ,5 ,4 ,all that gone with wind.,1);
  aforum[16] = new makeforum(21 , 谈情说爱 ,6 ,4 ,let"s talk about love.,2);
  aforum[17] = new makeforum(22 , 笑话站 ,7 ,4 ,just joke , whatever it is.,1);

</script>

<html>
<head>
<title>版块管理</title>
<meta http-equiv=content-type content=text/html; charset=gb2312>
<link rel=stylesheet href=images/style.css>
</head>
<body bgcolor=#ffffff  onload=on_load();>
<p align=center class=bigtitle>ematters board 版块管理</p>
<form name = frmmanager method=post action=changeforum.asp>
<table width=720 border=0 align=center cellspacing=1 cellpadding=4 bgcolor=#000000>
   <tr bgcolor=#ffffff>
      <td width=250 align=left>
        版块名称
      </td>
       <td width=70 align=center>
            
       </td>
      <td width=400 align=left>
        论坛名称
   </tr>
   <tr bgcolor=#ffffff>
      <td  align=left>
        <input type=text name=txtcategoryname size=20 value=请选择版块 disabled>
      </td>
       <td width=120 align=center>
           <input type=button name=btnchangename value=修改名称 disabled onclick=on_changename();>
       </td>
      <td  align=left>
        <input type=text name=txtforumname size=20 value=请选择论坛 disabled>
   </tr>
   <tr bgcolor=#ffffff>
      <td align=left>
        <select name=selcategoryname size=10 width=200 onchange=on_categorychange(); style=width:120>
        </select>
        <input type=button name=btnaddcategory value = 增加 onclick=on_addcategory();>
        <input type=button name=btndeletecategory value=删除 onclick=on_deletecategory();>
      </td>
      <td align=center>
         <br><br>
         <br><br>
         <input type=button name=btnup value=↑ onclick=on_orderup()>
         <br><br>
         <input type=button name=btndown value=↓ onclick=on_orderdown()>
      </td>
      <td align=left>
        <select name=selforumname size=10 onchange=on_forumchange(); style=width:200>
        </select>
        <input type=button name=btnaddforum value = 增加 onclick=on_addforum();>
        <input type=button name=btndeleteforum value=删除 onclick=on_deleteforum();>
   </tr>
   <tr bgcolor=#ffffff><td colspan=2 align=left>
      描述:
     <textarea name=txtdescription cols=30 style=overflow:hidden></textarea>
     <input type=button name=btnmodifydescription value=修改 onclick=on_changedescription()>
      </td>
     <td align=left>
      版主
       <select name=selmaster disabled>
            <option value=1>bigeagle</option>
            <option value=2>lizza</option>
       </select>
       <input type=button name=btnchangemaster value=修改 onclick=on_changemaster()>
   </td></tr>
   <tr bgcolor=#ffffff>
       <td colspan=3 align=left>
          <input type=button name=btnsubmit value=确认 onclick=on_submit();>
       </td>
   </tr>
</table>
</form>
</body></html>

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!
相关主题
文章页数:[1] 
Google
热门文章
·LB5000XP论坛配合SERV-U获取系统管理员权限-CGI教程,CGI文档
·CGI 版本-PHP教程,其它文章
·获取随机的由大小写字母和数字组成的八位密码-CGI教程,CGI文档
·Perl在NT下的快速简便安装方法 (转)-CGI教程,CGI文档
·实战 FastCGI(转)二-CGI教程,CGI文档
·XML和现代CGI应用程序-.NET教程,XML应用
·perl在win32平台上直接操作打印机-CGI教程,CGI文档
·实战 FastCGI(转)五(完)-CGI教程,CGI文档
·Python 快速入门(一)-CGI教程,CGI文档
·网站 PAGEVIEW 分析系统 CGI (原创)-CGI教程,CGI文档

最新文章
·顺便说说一些指示代码
·跟我学Perl(二)
·跟我学Perl(一)
·CGI教程(5)利用CGI解码FORM
·CGI教程(4)HTML 表单
·CGI教程(3)怎样发回文档给客户端
·CGI教程(2)怎样从服务器获得信息
·CGI教程(1)简介
·CGI教程(目录)
·Perl直接入门详尽指南




版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!

特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。
  打印  刷新  关闭
返回首页 |关于我们 | 联系我们 | 付款方式 | 创业联盟 | 虚拟主机 | 资讯中心 | 友情链接 | 网站地图

版权所有 西部数码(www.west263.com)
CopyRight (c) 2002~2006 west263.com all right reserved.
公司地址:四川成都市万和路90号天象大厦4楼 邮编:610031
电话总机:028-86262244 86263048 86263408 86263960 86264018 86267838
售前咨询:总机转201 202 203 204 206 208
售后服务:总机转211 212 213 214
财务咨询:总机转224 223 传真:028-86264041 财务QQ:点击发送消息给对方635483282
售前咨询QQ:点击发送消息给对方2182518 点击发送消息给对方241975952 点击发送消息给对方275026793 点击发送消息给对方408235859
售后服务QQ:点击发送消息给对方17708515 点击发送消息给对方307742704 点击发送消息给对方287976517 点击发送消息给对方363783715
《中华人民共和国增值电信业务经营许可证》编号:川B2-20030065号