求后台管理记录修改排列顺序的PHP代码转成ASP代码
求后台管理记录修改排列顺序的PHP代码转成ASP代码product_sort.php页代码:
==============================
<?
require('./global.php');
?>
<html>
<head>
<title>编辑产品排列顺序</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="comm.css" rel="stylesheet" type="text/css">
<script Language="JavaScript" src="FloatButton.js"></script>
<Script Language="JavaScript">
<!--
//提交结果函数,进行输入检查
function cmdSubmit_onclick(){
if(typeof(form1.allmodellist) == "object"){
var MenuList = document.all("allmodellist");
var MenuListLen = MenuList.options.length;
var strMnuModID = "";
var strSortOrder = "";
for(j=MenuListLen-1; j>=0; j--){
var k = j + 1;
strSortOrder += k + ",";
strMnuModID += MenuList.options[j].value + ",";
}
if(strSortOrder.substr(strSortOrder.length - 1, 1) == ','){
strSortOrder = strSortOrder.substr(0, strSortOrder.length - 1)
}
if(strMnuModID.substr(strMnuModID.length - 1, 1) == ','){
strMnuModID = strMnuModID.substr(0, strMnuModID.length - 1)
}
}
window.form1.mnuModIDs.value = strMnuModID;
window.form1.mnuOrders.value = strSortOrder;
form1.submit();
}
//读取工具栏页面中的默认选择项
function MenuMoveUp(){
var oOption, UpPosition, DownPositionj;
var ArryMenu = new Array()
var bFound = false;
var MenuList = document.all("allmodellist");
var MenuListLen = MenuList.options.length;
for (j=MenuListLen-1; j>=0; j--){
if (MenuList.options(j).selected) { //判断当前Option是否被选中
if (j == 0)
return;
bFound = true;
UpPosition = j - 1 ;
DownPosition = j ;
ArryMenu[(2*j)+1] = MenuList.options(j).text;
ArryMenu[2*j] = MenuList.options(j).value;
}
else{
ArryMenu[(2*j)+1] = MenuList.options(j).text;
ArryMenu[2*j] = MenuList.options(j).value;
}
}
if (bFound == false)
return;
for(j = MenuListLen-1;j>=0;j--){
MenuList.remove(j);
}
for(j = 0;j<=MenuListLen-1;j++){
if ( j == UpPosition ){
oOption = document.createElement("OPTION");
oOption.value= ArryMenu[(2*j)+2];
oOption.text= ArryMenu[(2*j)+3];
window.form1.allmodellist.add(oOption);
}
else{
if ( j == DownPosition ){
oOption = document.createElement("OPTION");
oOption.value= ArryMenu[(2*j)-2];
oOption.text= ArryMenu[(2*j)-1];
window.form1.allmodellist.add(oOption);
}
else{
oOption = document.createElement("OPTION");
oOption.value= ArryMenu[2*j];
oOption.text= ArryMenu[(2*j)+1];
window.form1.allmodellist.add(oOption);
}
}
}
MenuList.options(UpPosition).selected = true;
}
function MenuMoveDown(){
var oOption, UpPosition, DownPositionj;
var ArryMenu = new Array()
var bFound = false;
var MenuList = document.all("allmodellist");
var MenuListLen = MenuList.options.length;
for (j=MenuListLen-1; j>=0; j--){
if (MenuList.options(j).selected) { //判断当前Option是否被选中
if (j == MenuListLen - 1)
return;
bFound = true;
UpPosition = j ;
DownPosition = j + 1 ;
ArryMenu[(2*j)+1] = MenuList.options(j).text;
ArryMenu[2*j] = MenuList.options(j).value;
}
else{
ArryMenu[(2*j)+1] = MenuList.options(j).text;
ArryMenu[2*j] = MenuList.options(j).value;
}
}
if (bFound == false)
return;
for(j = MenuListLen-1;j>=0;j--){
MenuList.remove(j);
}
for(j = 0;j<=MenuListLen-1;j++){
if ( j == UpPosition ){
oOption = document.createElement("OPTION");
oOption.value= ArryMenu[(2*j)+2];
oOption.text= ArryMenu[(2*j)+3];
window.form1.allmodellist.add(oOption);
}
else{
if ( j == DownPosition ){
oOption = document.createElement("OPTION");
oOption.value= ArryMenu[(2*j)-2];
oOption.text= ArryMenu[(2*j)-1];
window.form1.allmodellist.add(oOption);
}
else{
oOption = document.createElement("OPTION");
oOption.value= ArryMenu[2*j];
oOption.text= ArryMenu[(2*j)+1];
window.form1.allmodellist.add(oOption);
}
}
}
MenuList.options(DownPosition).selected = true;
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</Script>
</head>
<body leftmargin="0" topmargin="0" onLoad="MM_preloadImages('images/up1.gif','images/down1.gif')">
<form action="modify_product_sort.php" method="post" enctype="multipart/form-data" name="form1">
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td class="important" bgcolor="#dddddd">当前分类 <b><?echo geteptypename($typeid)?></b> 产品排序:</td>
</tr>
<tr>
<td align="center">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="200">
<SELECT name="allmodellist" class="sel" size="16" style="width:250px">
<?
$pro=$DB_site->query("select * from tb_eproducts where typeid=$typeid order by sortnum");
while ($proinfo=$DB_site->fetch_array($pro)) {
echo "<Option value='".$proinfo[productid]."'>".$proinfo[pnumber]."(".htmlspecialchars($proinfo
[name]).")</option>";
}
?>
</SELECT>
</td>
<td width="35">
<table border=0
cellspacing=0 cellpadding=0 align=center width=71%>
<tr>
<td height="68" align="center">
<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage
('Image3','','images/up1.gif',1)" onClick="MenuMoveUp();" ><img src="images/up.gif" name="Image3" width="22"
height="40" border="0" alt="向上移动"></a></td>
</tr>
<tr>
<td height="70" align="center"><a href="#"
onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image4','','images/down1.gif',1)"
onClick="MenuMoveDown();" ><img src="images/down.gif" name="Image4" width="22" height="40" border="0" alt="向下移
动"></a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">
<input type="hidden" name="mnuModIDs" value="">
<input type="hidden" name="mnuOrders" value="">
<input type="submit" name="Submit" value="确认排序" onClick="cmdSubmit_onclick()"> <input type="button"
name="Submit3" value="取消排序" onClick="window.close()">
<input name="typeid" type="hidden" value="<?echo $typeid?>">
<input name="action" type="hidden" value="edit"> <input name="location" type="hidden" value="step1"></td>
</tr>
</table>
</form>
</body>
</html>
===========================================
modify_product_sort.php页代码:
============================================
<?
require('./global.php');
#######################编辑产品######################
$modelarray=explode(",",$mnuModIDs);
$orderarray=explode(",",$mnuOrders);
if($action=="edit") {
if(count($modelarray)!=0){
for($ii=0; $ii<count($modelarray); $ii++) {
$proid=$modelarray[$ii];
$sortnum=$orderarray[$ii];
$DB_site->query("update tb_edownload set sortnum='$sortnum' where id='$proid'");
}
}
refreshmain();
showmsggo("产品排列顺序更新成功!","edownload_sort.php?typeid=$typeid");
}
###################################################
?>