js 树形菜单(php ajax可刷新)

 更新时间:2016年11月25日 15:53  点击:1946
本文章是利用了js php ajax css实现的一款可刷新的js 树形菜单,如果你正在找这类型的类型的树形菜单可以进来免费下载。
 代码如下 复制代码

<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.111cn.net/tr/xhtml1/dtd/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>simpletree drag</title>
<style>
body
{
 font: normal 12px arial, tahoma, helvetica, sans-serif;
 margin:0;
 padding:20px;
}
.simpletree
{
 
 margin:0;
 padding:0;
 /*
 overflow:auto;
 width: 250px;
 height:350px;
 overflow:auto;
 border: 1px solid #444444;
 */
}
.simpletree li
{
 list-style: none;
 margin:0;
 padding:0 0 0 34px;
 line-height: 14px;
}
.simpletree li span
{
 display:inline;
 clear: left;
 white-space: nowrap;
}
.simpletree ul
{
 margin:0;
 padding:0;
}
.simpletree .root
{
 margin-left:-16px;
 background: url(images/root.gif) no-repeat 16px 0 #ffffff;
}
.simpletree .line
{
 margin:0 0 0 -16px;
 padding:0;
 line-height: 3px;
 height:3px;
 font-size:3px;
 background: url(images/line_bg.gif) 0 0 no-repeat transparent;
}
.simpletree .line-last
{
 margin:0 0 0 -16px;
 padding:0;
 line-height: 3px;
 height:3px;
 font-size:3px;
 background: url(images/spacer.gif) 0 0 no-repeat transparent;
}
.simpletree .line-over
{
 margin:0 0 0 -16px;
 padding:0;
 line-height: 3px;
 height:3px;
 font-size:3px;
 background: url(images/line_bg_over.gif) 0 0 no-repeat transparent;
}
.simpletree .line-over-last
{
 margin:0 0 0 -16px;
 padding:0;
 line-height: 3px;
 height:3px;
 font-size:3px;
 background: url(images/line_bg_over_last.gif) 0 0 no-repeat transparent;
}
.simpletree .folder-open
{
 margin-left:-16px;
 background: url(images/collaps教程able.gif) 0 -2px no-repeat #fff;
}
.simpletree .folder-open-last
{
 margin-left:-16px;
 background: url(images/collapsable-last.gif) 0 -2px no-repeat #fff;
}
.simpletree .folder-close
{
 margin-left:-16px;
 background: url(images/expandable.gif) 0 -2px no-repeat #fff;
}
.simpletree .folder-close-last
{
 margin-left:-16px;
 background: url(images/expandable-last.gif) 0 -2px no-repeat #fff;
}
.simpletree .doc
{
 margin-left:-16px;
 background: url(images/leaf.gif) 0 -1px no-repeat #fff;
}
.simpletree .doc-last
{
 margin-left:-16px;
 background: url(images/leaf-last.gif) 0 -1px no-repeat #fff;
}
.simpletree .ajax
{
 background: url(images/spinner.gif) no-repeat 0 0 #ffffff;
 height: 16px;
 display:none;
}
.simpletree .ajax li
{
 display:none;
 margin:0;
 padding:0;
}
.simpletree .trigger
{
 display:inline;
 margin-left:-32px;
 width: 28px;
 height: 11px;
 cursor:pointer;
}
.simpletree .text
{
 cursor: default;
}
.simpletree .active
{
 cursor: default;
 background-color:#f7be77;
 padding:0px 2px;
 border: 1px dashed #444;
}
#drag_container
{
 background:#ffffffwww.111cn.net;
 color:#000;
 font: normal 11px arial, tahoma, helvetica, sans-serif;
 border: 1px dashed #767676;
}
#drag_container ul
{
 list-style: none;
 padding:0;
 margin:0;
}

#drag_container li
{
 list-style: none;
 background-color:#ffffff;
 line-height:18px;
 white-space: nowrap;
 padding:1px 1px 0px 16px;
 margin:0;
}
#drag_container li span
{
 padding:0;
}

#drag_container li.doc, #drag_container li.doc-last
{
 background: url(images/leaf.gif) no-repeat -17px 0 #ffffff;
}
#drag_container .folder-close, #drag_container .folder-close-last
{
 background: url(images/expandable.gif) no-repeat -17px 0 #ffffff;
}

#drag_container .folder-open, #drag_container .folder-open-last
{
 background: url(/http://mb.111cn.net/collapsable.gif) no-repeat -17px 0 #ffffff;
}
.contextmenu
{
 display:none;
}
</style>
<script type="text/网页特效" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.simple.tree.js"></script>
<script type="text/javascript">
var simpletreecollection;
$(document).ready(function(){
 simpletreecollection = $('.simpletree').simpletree({
  autoclose: true,
  afterclick:function(node){
   //alert("text-"+$('span:first',node).text());
  },
  afterdblclick:function(node){
   //alert("text-"+$('span:first',node).text());
  },
  aftermove:function(destination, source, pos){
   //alert("destination-"+destination.attr('id')+" source-"+source.attr('id')+" pos-"+pos);
  },
  afterajax:function()
  {
   //alert('loaded');
  },
  animate:true
  //,doctofolderconvert:true
 });
});
</script>
</head>

<body>
<div class="contextmenu" id="mymenu1">
 <ul>
  <li id="add"><img src="images/folder_add.png" /> add child</li>
  <li id="reload"><img src="images/arrow_refresh.png" /> reload</li>
  <li id="edit"><img src="images/folder_edit.png" /> edit</li>
  <li id="delete"><img src="images/folder_delete.png" /> delete</li>
 </ul>
</div>
<div class="contextmenu" id="mymenu2">
 <ul>
  <li id="edit"><img src="images/page_edit.png" /> edit</li>
  <li id="delete"><img src="images/page_delete.png" /> delete</li>
 </ul>
</div>
<ul class="simpletree">
 <li class="root" id='1'><span>tree root 1</span>
  <ul>
   
   <li class="open" id='2'><span>tree node 1</span>
    <ul>
     
     <li id='3'><span>tree node 1-1</span>
      <ul class="ajax">
       <li id='4'>{url:loadtree.php?tree_id=1}</li>
      </ul>
     </li>
     
    </ul>
   </li>
   
   <li id='5'><span>tree node 2</span>
    <ul>
     
     <li id='6'><span>tree node 2-1</span>
      <ul>
       
       <li id='7'><span>tree node 2-1-1</span></li>
       
       <li id='8'><span>tree node 2-1-2</span></li>
       
       <li id='9'><span>tree node 2-1-3</span></li>
       
       <li id='10'><span>tree node 2-1-4www.aimeige.com.cn</span>
        <ul class="ajax">
         <li id='11'>{url:loadtree.php?tree_id=1}</li>
        </ul>
       </li>
       
      </ul>
     </li>
     
     <li id='12'><span>tree node 2-2</span>
      <ul>
       
       <li id='13'><span>tree node 2-2-1</span></li>
       
      </ul>
     </li>
     
     
     <li id='14'><span>tree node 2-3</span>
      <ul>
       
       <li id='15'><span>tree node 2-3-1</span>
         <ul>
          
          <li id='16'><span>tree node 2-3-1-1</span></li>
          
          <li id='17'><span>tree node 2-3-1-2</span></li>
          
          <li id='18'><span>tree node 2-3-1-3</span>
           <ul>
            
            <li id='19'><span>tree node 2-3-1-3-1</span></li>
            
           </ul>
          </li>
          
          <li id='20'><span>tree node 2-3-1-4</span></li>
          
          <li id='21'><span>tree node 2-3-1-5</span></li>
          
          <li id='22'><span>tree node 2-3-1-6</span>
           <ul>
            
            <li id='23'><span>tree node 2-3-1-6-1</span></li>
            
           </ul>
          </li>
          
          <li id='24'><span>tree node 2-3-1-7</span></li>
          
          <li id='25'><span>tree node 2-3-1-8</span></li>
          
          <li id='26'><span>tree node 2-3-1-9</span>
           <ul>
            
            <li id='27'><span>tree node 2-3-1-9-1</span></li>
            
           </ul>
          </li>
          
         </ul>
       </li>
       
      </ul>
     </li>
     
    </ul>
   </li>
   
  </ul>
 </li>
</ul>

</body>

</html>

php文件
<li id='35'><span class="text">tree node ajax 1</span></li>
<li id='36'><span class="text">tree node ajax 2</span></li>
<li id='37'><span class="text">tree node ajax 3</span>
 <ul>
  <li id='38'><span class="text">tree node ajax 3-1</span>
   <ul>
    <li id='39'><span class="text">tree node ajax 3-1-1</span></li>
    <li id='40'><span class="text">tree node ajax 3-1-2</span></li>
    <li id='41'><span class="text">tree node ajax 3-1-3</span></li>
    <li id='42'><span class="text">tree node ajax 3-1-4</span></li>
   </ul>
  </li>
  <li id='43'><span class="text">tree node ajax 3-2</span></li>
  <li id='44'><span class="text">tree node ajax 3-3</span>
   <ul>
    <li id='45'><span class="text">tree node ajax 3-3-1</span></li>
    <li id='46'><span class="text">tree node ajax 3-3-2</span></li>
    <li id='47'><span class="text">tree node ajax 3-3-3</span></li>
   </ul>
  </li>
  <li id='48'><span class="text">tree node ajax 3-4</span></li>
  <li id='49'><span class="text">tree node ajax 3-5</span>
   <ul>
    <li id='50'><span class="text">tree node ajax 3-5-1</span></li>
    <li id='51'><span class="text">tree node ajax 3-5-2</span></li>
    <li id='52'><span class="text">tree node ajax 3-5-3</span></li>
   </ul>
  </li>
  <li id='53'><span class="text">tree node ajax 3-6</span></li>
 </ul>
</li>
<li id='54'><span class="text">tree node ajax 4</span></li>

源码下载
http://down.111cn.net/down/code/jquery/2010/1014/21200.html
效果预览
http://g.111cn.net/javascript/code/20101012/tree

这是一款老外写的mysql php接受数据过来然后进行数据保存在mysql_real_escape_string(nl2br(strip_tags($_POST[\'comment\'])));我觉得写得我们有一点区别吧。

database config
 */

 代码如下 复制代码

$db_host  = 'localhost';
$db_user  = 'root';
$db_pass  = '';
$db_database = '';

$link = mysql_connect($db_host,$db_user,$db_pass) or die('unable to establish a db connection');

mysql_select_db($db_database,$link);
mysql_query("set names utf8");


if(empty($_post['comment'])) die("0");
// if there isn't a comment text, exit

$comment = mysql_real_escape_string(nl2br(strip_tags($_post['comment'])));
$user='demo';
// this would be a nice place to start customizing - the default user
// you can integrate it to any site and show a different username.

$addon='';
if($_post['parent']) $addon=',parent='.(int)$_post['parent'];

mysql_query("insert into wave_comments set usr='".$user."', comment='".$comment."', dt=now()".$addon);

if(mysql_affected_rows($link)==1)
 echo mysql_insert_id($link);
 // if the insert was successful, echo the newly assigned id
else
 echo '0';
?>

sql

--
-- table structure for table `wave_comments`
--

create table `wave_comments` (
  `id` int(11) not null auto_increment,
  `parent` int(11) not null default '0',
  `usr` varchar(16) collate utf8_unicode_ci not null default '',
  `comment` text collate utf8_unicode_ci not null,
  `dt` datetime not null default '0000-00-00 00:00:00',
  primary key  (`id`),
  key `parent` (`parent`,`id`)
) engine=myisam  default charset=utf8 collate=utf8_unicode_ci;

--
-- dumping data for table `wave_comments`
--

insert into `wave_comments` values(1, 0, 'tutorialzine', 'this is a demo for a tutorialzine tutorial about creating a google wave-like history slider.<br /><br />rnto get started, just drag the slider above, and this thread will be reverted to a past state.', '2009-10-24 03:58:08');
insert into `wave_comments` values(2, 0, 'curious', 'is html allowed in the comments?', '2009-10-24 03:59:44');
insert into `wave_comments` values(3, 2, 'tutorialzine', 'nope. also the messages in this demo are deleted every hour to prevent spamming.', '2009-10-24 04:00:15');
insert into `wave_comments` values(4, 1, 'tutorialzine', 'in this tutorial we are using <b>php</b>, <b>mysql</b>, <b>jquery</b> and <b>css教程</b>. the slider was created with <b>jquery ui</b>. <a href="http://111cn.net/2009/10/google-wave-history-slider-jquery/" target="_blank">view the tutorial</a>.', '2009-10-24 04:01:34');
insert into `wave_comments` values(5, 2, 'curious', 'thanks! also i noticed that you can click, rather than drag the slider.great!', '2009-10-24 04:11:48');

本文章收藏了一款简单php文件上传实例哦,这真的是一款超级简单的文件上传功能代码哦,我们利用php $files来获取要上传文件的,类型,名称与临时名称然后用move_uploaded_file把要上传文件保存到服务器指定目录就OK了。

html代码

 代码如下 复制代码
<input   type= "file "   id= "userfile "   name= "userfile ">
<input   type= "submit "   name= "upload "   value= "上传 ">

处理上传php代码

 

 代码如下 复制代码
<?php
function   do_upload($upload_dir,$upload_url)
    {
          $temp_name   =   $_files[ 'userfile '][ 'tmp_name '];
          $file_name   =   $_files[ 'userfile '][ 'name '];
          $file_name   =   str_replace( "\ ", " ",$file_name);
          $file_name   =   str_replace( " ' ", " ",$file_name);
          $file_path   =   $upload_dir.$file_name;
          $thistime=explode( "- ",date( "y-m-d-h-i-s "));
          $thistime=mktime();
          $filename=$thistime.substr($file_name,strrpos($file_name, ". "));
          //文件名检查
        if($file_name   =   ' ')
            {
                echo   "文件名无效。 ";
                exit;
            }
      if(@move_uploaded_file($_files[ 'userfile '][ 'tmp_name '],$upload_dir.$filename))
          {
                echo   "上传成功。 ";
                echo   " <meta   http-equiv= "refresh "   content= "1;url=www.aimeige.com.cn.php "> ";
                exit;
          }else
            {
                echo   "上传失败。 ";
                echo   " <meta   http-equiv= "refresh "   content= "1;url=www.111cn.net.php "> ";
                exit;
            }
        echo   "end ";
    }
?>
 代码如下 复制代码
调用方法
 代码如下 复制代码
$upload_dir ='down.111cn.net'; $upload_url='www.111cn.net';
 代码如下 复制代码
 do_upload($upload_dir,$upload_url) ;
关于缓存技术不只在php有,很多系统都有,这是为了减轻服务吕压力与数据库压力来做的,本文章从php缓存技术入门到利用缓存实例来告诉你如何应用php来实例文件缓存描述。

先看这个缓存类

<?php

 代码如下 复制代码

class cache{
/*
class name: cache
description: control to cache data,$cache_out_time is a array to save cache date time out.
version: 1.0
author: 老农 cjjer
last modify:2006-2-26
author url: http://www.111cn.net*/
private $cache_dir;
private $expiretime=180;//缓存的时间是 60 秒
function __construct($cache_dirname){
    if(!@is_dir($cache_dirname)){
        if(!@mkdir($cache_dirname,0777)){
        $this->warn('缓存文件不存在而且不能创建,需要手动创建.');
        return false;
        }
    }
$this->cache_dir    =    $cache_dirname;
}
function __destruct(){
    echo 'cache class bye.';
}

function get_url() {
        if (!isset($_server['request_uri'])) {
                $url = $_server['request_uri'];
        }else{
                $url = $_server['script_name'];
                $url .= (!empty($_server['query_string'])) ? '?' . $_server['query_string'] : '';
        }

        return $url;
}

function warn($errorstring){
echo "<b><font color='red'>发生错误:<pre>".$errorstring."</pre></font></b>";
}

function cache_page($pageurl,$pagedata){
    if(!$fso=fopen($pageurl,'w')){
        $this->warns('无法打开缓存文件.');//trigger_error
        return false;
    }
    if(!flock($fso,lock_ex)){//lock_nb,排它型锁定
        $this->warns('无法锁定缓存文件.');//trigger_error
        return false;
    }
    if(!fwrite($fso,$pagedata)){//写入字节流,serialize写入其他格式
        $this->warns('无法写入缓存文件.');//trigger_error
        return false;
    }
    flock($fso,lock_un);//释放锁定
    fclose($fso);
    return true;
}

 

本文章为你提供一款php简单的伪原创程序哦,如果你正在找伪原创程序这是一款简单的php做的代码哦。

db2word.php

 代码如下 复制代码
<?php
//将数据库教程以数组形式写到文件中
require("conn.php");
$res=mysql教程_query("select k1,k2 from ".table('keywords')." ") ;
$str="<?php ";
while($rs=mysql_fetch_array($res))
{
$str .="$keyword['".$rs[0]."']='".$rs[1]."'; ";
}
$str.="?>";
file_put_contents("keyword.php",$str);
echo "导出成功";
?>

代码二

 代码如下 复制代码
<?php
//将文件中的数组写入到数据库中
require("conn.php");
@require("keyword.php");
mysql_query("delete from ".table('keywords')."");
foreach($keyword as $key=>$val)
{
//$key=iconv('utf-8','gbk',$key);
//$val=iconv('utf-8','gbk',$val);
$pinyin=getfirstchar($key);
$ct=mysql_query("select count(*) from ".table('keywords')." where k1='$key' and k2='$val'");//检测是否已经存在
$ct=@mysql_fetch_array($ct);
$ct=$ct[0];
if($ct<=0)//不存在则插入
{
mysql_query("insert into ".table('keywords')."(k1,k2,pinyin) values('$key','$val','$pinyin')") or die("出错");
}
}
echo "插入成功!";
?>

同意词

[!--infotagslink--]

相关文章

  • jQuery实现非常实用漂亮的select下拉菜单选择效果

    本文实例讲述了jQuery实现非常实用漂亮的select下拉菜单选择效果。分享给大家供大家参考,具体如下:先来看如下运行效果截图:在线演示地址如下:http://demo.jb51.net/js/2015/js-select-chose-style-menu-codes/具体代码如...2015-11-08
  • JS基于Mootools实现的个性菜单效果代码

    本文实例讲述了JS基于Mootools实现的个性菜单效果代码。分享给大家供大家参考,具体如下:这里演示基于Mootools做的带动画的垂直型菜单,是一个初学者写的,用来学习Mootools的使用有帮助,下载时请注意要将外部引用的mootools...2015-10-23
  • JS实现的简洁纵向滑动菜单(滑动门)效果

    本文实例讲述了JS实现的简洁纵向滑动菜单(滑动门)效果。分享给大家供大家参考,具体如下:这是一款纵向布局的CSS+JavaScript滑动门代码,相当简洁的手法来实现,如果对颜色不满意,你可以试着自己修改CSS代码,这个滑动门将每一...2015-10-21
  • php无刷新利用iframe实现页面无刷新上传文件(1/2)

    利用form表单的target属性和iframe 一、上传文件的一个php教程方法。 该方法接受一个$file参数,该参数为从客户端获取的$_files变量,返回重新命名后的文件名,如果上传失...2016-11-25
  • jQuery实现有动画淡出效果的二级折叠菜单代码

    本文实例讲述了jQuery实现有动画淡出效果的二级折叠菜单代码。分享给大家供大家参考,具体如下:这里介绍jQuery实现有动画淡出效果的二级折叠菜单代码,相当不错,因考虑功能的实现,所以没有怎么美化,不过这样也好,可以给大家更...2015-10-21
  • jQuery+PHP发布的内容进行无刷新分页(Fckeditor)

    这篇文章将使用jQuery,并结合PHP,将Fckeditor发布的内容进行分页,并且实现无刷新切换页面。 本文假设你是WEB开发人员,掌握了jQuery和PHP相关知识,并且熟知Fckeditor的配置和使用。...2015-10-23
  • jQuery实现下拉菜单滑动效果

    这篇文章主要为大家详细介绍了jQuery实现下拉菜单滑动效果,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-08-09
  • 解决vue刷新页面以后丢失store的数据问题

    这篇文章主要介绍了解决vue刷新页面以后丢失store的数据问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-08-12
  • jQuery实现可关闭固定于底(顶)部的工具条菜单效果

    本文实例讲述了jQuery实现可关闭固定于底(顶)部的工具条菜单效果。分享给大家供大家参考,具体如下:这是一款可关闭始终在页面底部的工具条菜单,浮动在页面顶部的大家见的比较多了,本款从形式上来说与其它的没什么差别,只是浮...2015-11-08
  • js如何构造elementUI树状菜单的数据结构详解

    由于业务需要,要求实现树形菜单,且菜单数据由后台返回,下面这篇文章主要给大家介绍了关于js如何构造elementUI树状菜单的数据结构的相关资料,需要的朋友可以参考下...2021-05-13
  • jQuery+PHP+MySQL二级联动下拉菜单实例讲解

    二级联动下拉菜单选择应用在在很多地方,比如说省市下拉联动,商品大小类下拉选择联动。本文将通过实例讲解使用jQuery+PHP+MySQL来实现大小分类二级下拉联动效果。 实现效果:当选择大类时,小类下拉框里的选项内容也随着改...2015-10-30
  • 解决vuex数据页面刷新后初始化操作

    这篇文章主要介绍了解决vuex数据页面刷新后初始化操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-07-26
  • Vue.js 递归组件实现树形菜单(实例分享)

    本文主要对介绍利用Vue.js 的递归组件,实现了一个最基本的树形菜单。具有很好的参考价值,下面就跟着小编一起来看下吧...2017-01-09
  • java后台实现js关闭本页面,父页面指定跳转或刷新操作

    这篇文章主要介绍了java后台实现js关闭本页面,父页面指定跳转或刷新操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-11-16
  • jQuery实现精美的多级下拉菜单特效

    这是一款精美的多级下拉菜单美化,可以完美替代“select”来实现下拉菜单的效果。而且支持多级菜单,有加载等待效果,有层级分类展示。复制代码 代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "ht...2015-03-15
  • 基于jquery实现表格无刷新分页

    这篇文章主要介绍了基于jquery实现表格无刷新分页,功能实现了前端排序功能,增加了前端搜索功能,感兴趣的小伙伴们可以参考一下...2016-01-08
  • php+ajax制作无刷新留言板

    本文就是和大家分享一款由php结合ajax实现的无刷新留言板,先给大家看一下最后的效果图:数据库连接代码如下: <&#63;php$conn = @mysql_connect("localhost","root","root") or die ("MySql连接错误");mysql_select_db("d...2015-10-30
  • jquery插件实现悬浮的菜单

    这篇文章主要为大家详细介绍了jquery插件实现悬浮的菜单,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-04-23
  • Vue 中获取当前时间并实时刷新的实现代码

    这篇文章主要介绍了Vue 中获取当前时间并实时刷新,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-05-13
  • vue实现在进行增删改操作后刷新页面

    这篇文章主要介绍了vue实现在进行增删改操作后刷新页面,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-08-05