欢迎来到福编程网,本站提供各种互联网专业知识!

php+dojo 的数据库保存拖动布局的一个方法dojo 这里下载

发布时间:2007-03-07 作者: 来源:转载
看老大介绍的dojo框架,学习着写了下。刚开始学习php请大家指教下!发现发不了附件。发两个代码大家自己体会了。复制代码代码如下://引用以下两个dojo包dojo.require("dojo.style");dojo.require("dojo.dnd.*");functioninit(){//利用classname取到元素列
看老大介绍的dojo框架,学习着写了下。刚开始学习php请大家指教下!发现发不了附件。发两个代码大家自己体会了。
复制代码 代码如下:
session_start();
if($_SESSION['gh']==''){
header('location:login.php');
}
include("config.php");
$sql="select*frommodule";
$result=mssql_query($sql,$conn);
$num=mssql_num_rows($result);
//echo$num;
?>





//引用以下两个dojo包
dojo.require("dojo.style");
dojo.require("dojo.dnd.*");
functioninit(){
//利用classname取到元素列表,将其注册为dojo.dnd.HtmlDragSour
vararr=dojo.html.getElementsByClass('divdrag')
for(vari=0;ivarparentDiv=arr.parentNode.id
newdojo.dnd.HtmlDragSource(arr,parentDiv);
}
//定义容器
newdojo.dnd.HtmlDropTarget("container0",["container0",echo'"'.'container'.$p.'"';
if($p!=$num){
echo",";
}
}
echo']);';

for($p=1;$p<=$num;$p++){
echochr(13).'newdojo.dnd.HtmlDropTarget("container'.$p.'",["container0",';
for($o=1;$o<=$num;$o++){
echo'"container'.$o.'"';
if($o!=$num){
echo",";
}
}
echo']);';
}
echochr(13);

?>
}
//增加到window.onload事件中
window.onload=function(){init();}
functionbjsave(){
gr=""
$sql='selectidfrommodule';
$result=mssql_query($sql,$conn);
while($myrow=mssql_fetch_array($result))
echo'if(mokuai'.$myrow['id'].'.parentElement.id!="container0"){'.chr(13).'gr=gr+'.$myrow['id'].'+"|"+mokuai'.$myrow['id'].'.parentElement.id+"$"'.chr(13).'}'.chr(13);
?>
form1.gr.value=gr;
form1.submit();
}



$sql='select*frommodulewhereidnotin(selectmokuaiidfromgerenwheregh='.$_SESSION['gh'].')';
$result=mssql_query($sql,$conn);
while($myrow=mssql_fetch_array($result))
echo''.$myrow['mn'].'';
?>




for($p=1;$p<=$num;$p=$p+2){
echo'';
$sql='selectmokuaiidfromgerenwherebiaogeid='.$p.'andgh='.$_SESSION['gh'];
$result=mssql_query($sql,$conn);
while($myrow=mssql_fetch_array($result)){
$sql='select*frommodulewhereid='.$myrow['mokuaiid'];
$result1=mssql_query($sql,$conn);
while($myrow1=mssql_fetch_array($result1)){
echo''.$myrow1['mn'].'';
}
}
echo'
';
}
?>

for($p=2;$p<=$num;$p=$p+2){
echo'';
$sql='selectmokuaiidfromgerenwherebiaogeid='.$p.'andgh='.$_SESSION['gh'];
$result=mssql_query($sql,$conn);
while($myrow=mssql_fetch_array($result)){
$sql='select*frommodulewhereid='.$myrow['mokuaiid'];
$result1=mssql_query($sql,$conn);
while($myrow1=mssql_fetch_array($result1)){
echo''.$myrow1['mn'].'';
}
}
echo'
';
}
?>







复制代码 代码如下:
session_start();
if($_SESSION['gh']==''){
header('location:login.php');
}
include("config.php");
$sql='deletefromgerenwheregh='.$_SESSION['gh'];
mssql_query($sql);
$gr=str_replace("container","",$_POST['gr']);
//echo$gr;
$array=explode("$",$gr);
for($i=0;$i<=count($array)-2;$i++){
$add=explode("|",$array[$i]);
$sql='insertintogeren(mokuaiid,biaogeid,gh)values("'.$add[0].'","'.$add
[1].'","'.$_SESSION['gh'].'")';
//echo$sql.'

';
mssql_query($sql);
}
header("location:view.php");
?>

dojo 这里下载 http://download.dojotoolkit.org/release-0.3.1/dojo-0.3.1-ajax.zip

相关推荐