争怎路由网/网站教程/内容

客户端CGI——结合javascript、dhtml完成bbs的backoffice(二)

网站教程2024-06-19 阅读
//页面显示出来了,下面的任务就是对它们进行操作了。以下都是前台javascript函数。第一步,首先在window.onload事件中根据数组aCategory来生成选择框selCategory的option值。

function On_Load()
{

//初始化
frmManager.btnChangeMaster .disabled= true ;
frmManager.btnChangeName .disabled= true ;
frmManager.btnDeleteCategory .disabled= true ;
frmManager.btnDown .disabled= true ;
frmManager.btnModifyDescription .disabled = true ;
frmManager.btnUp .disabled= true ;
frmManager.btnAddForum .disabled= true ;
frmManager.btnDeleteForum .disabled = true ;

//首先生成selCategory的option

frmManager.selCategoryName.options.length = 0;
for (var i = 0 ; i < aCategory.length ; i++)
 {
 var newOption = document.createElement("OPTION") ;
 newOption.value = aCategory[i].CategoryID ;
 newOption.text = aCategory[i].CategoryName;
 frmManager.selCategoryName .add (newOption , i) ;
}

}

//第二步,我们利用selCategory的onchange事件来实现selForum的显示,利用selForm的onchange事件来实现它们相关信息的显示。

function On_CategoryChange()
{

frmManager.btnChangeName .disabled= false ;
frmManager.btnDeleteCategory .disabled= false ;
frmManager.btnDown .disabled= false ;
frmManager.btnUp .disabled= false ;
frmManager.btnAddForum .disabled= false ;
frmManager.btnModifyDescription .disabled = true ;
frmManager.btnChangeMaster .disabled= true ;
frmManager.btnAddCategory .disabled = false ;
frmManager.btnDeleteForum .disabled = true ;



frmManager.selForumName.options.length = 0 ;
if (frmManager.selCategoryName .selectedIndex != -1)
{
frmManager.txtCategoryName.value = frmManager.selCategoryName[frmManager.selCategoryName.selectedIndex].text ;
}
frmManager.txtForumName.value = ""
frmManager.txtDescription .value = ""
for (var i = 0 ; i < aForum.length ; i ++)
 {
 if (aForum[i].RootCategoryID == frmManager.selCategoryName.value)
 {
 var newOption = document.createElement("OPTION") ;
 newOption.value = aForum[i].CategoryID ;
 newOption.text = aForum[i].CategoryName
 frmManager.selForumName .add (newOption , i) ;
 }
 }
}
function On_ForumChange()
{

frmManager.btnChangeMaster .disabled= false ;
frmManager.btnChangeName .disabled= false ;
frmManager.btnDeleteCategory .disabled= true ;
frmManager.btnAddCategory .disabled = true ;
frmManager.btnDown .disabled= false ;
frmManager.btnModifyDescription .disabled = false ;
frmManager.btnUp .disabled= false ;
frmManager.btnAddForum .disabled= false ;
frmManager.btnDeleteForum .disabled = false ;


var intForumIndex ;
for (var i = 0 ; i < aForum.length ; i ++)
 {
 if (frmManager.selForumName[frmManager.selForumName.selectedIndex].value == aForum[i].CategoryID )
 {
 intForumIndex = i ;
 break ;
 }
 }
var intMasterIndex ;
for (var i = 0 ; i < frmManager.selMaster .options.length ; i ++)
 {
 if (frmManager.selMaster .options [i].value == aForum[intForumIndex].MasterID)
 {
 intMasterIndex = i ;
 break ;
 }
 }
//alert(intMasterIndex); 
frmManager.selMaster .value = frmManager.selMaster .options [intMasterIndex].value ; 
frmManager.selMaster .text = frmManager.selMaster .options [intMasterIndex].text ; 
 
frmManager.txtForumName.value = frmManager.selForumName[frmManager.selForumName.selectedIndex].text ;
frmManager.txtDescription.value = aForum[intForumIndex].Description ;
frmManager.txtDescription.disabled = true ;
}

//第三步,实现对栏目及相关论坛的改名操作

function On_ChangeName()
{
 if (frmManager.btnChangeName.value == "修改名称")
{
frmManager.btnChangeName.value= "确定"
frmManager.selCategoryName.disabled = true
frmManager.selForumName.disabled = true
frmManager.txtCategoryName.disabled = false
frmManager.txtForumName.disabled = false

frmManager.btnChangeMaster .disabled= true ;
frmManager.btnDeleteCategory .disabled= true ;
frmManager.btnDown .disabled= true ;
frmManager.btnModifyDescription .disabled = true ;
frmManager.btnUp .disabled= true ;
frmManager.btnAddForum .disabled= true ;
frmManager.btnDeleteForum .disabled = true ;
frmManager.btnAddCategory .disabled = true ;
frmManager.btnSubmit .disabled= true ;


}
 else
{

frmManager.btnSubmit .disabled = false ;

frmManager.btnChangeName.value= "修改名称"
var CategoryIndex = frmManager.selCategoryName.selectedIndex ;
var ForumIndex = frmManager.selForumName.selectedIndex ;
for (var i = 0 ; i < aCategory.length ; i ++)
{
if (aCategory[i].CategoryID == frmManager.selCategoryName[CategoryIndex].value)
 {
aCategory[i].CategoryName = frmManager.txtCategoryName.value
 }
 }
if (ForumIndex != -1)
 {
 for (var i = 0 ; i < aForum.length ; i ++)
{
 if (aForum[i].CategoryID == frmManager.selForumName[ForumIndex].value)
 {
 aForum[i].CategoryName = frmManager.txtForumName.value
 }
 }
 }
 On_Load();
 frmManager.selCategoryName.selectedIndex = CategoryIndex ;
 On_CategoryChange();
frmManager.selCategoryName.disabled = false
frmManager.selForumName.disabled = false
frmManager.txtCategoryName.disabled = true
frmManager.txtForumName.disabled = true

}
}


……

相关阅读