本文目錄一覽:
求一個PHP的簡單功能,求大神指導。
jQuery運用ajax實現滑鼠單擊修改內容實例
表格中的一行的代碼如下:
1tr
2 tdspan class=”catid”2/span/td
3 td2/td
4
5 tdspan class=”listorder” title=”點擊修改”2/span/td
6/tr
大致思路如下:
1、點擊欄目排序欄目中的數字,獲取同一行的第一列中的內容,即欄目id
2、隱藏欄目排序中的數字
3、在欄目排序列中插入input框,並在input框中顯示欄目排序中的內容,並設置為焦點
4、修改input中的內容,失去焦點的時候提交數據,用ajax向伺服器傳遞數據 方法為post方法
5、提交數據的時候,友好提示修改中。。。 或者等待圖片
6、返回成功信息 ,重新顯示修改後的內容 去掉input框
jquery核心代碼如下
01$(‘.listorder’).click(function(e){
02 var catid = $(this).parent().siblings(“td:eq(0)”).text();//獲取同一行上 第一列中的id值
03 var listorder_now_text = $(this).text();//獲取listorder中的內容 先保存起來
04 $(this).text(“”);//設置內容為空
05 var list_form = ‘input type=”text” value=”‘+listorder_now_text+'” size=2 class=”listorder_input” /’ ;
06 $(this).parent().append(list_form); //插入 input框
07 $(“.listorder_input”).focus();
08
09//自定義一個div 提示修改中
10 var loading = ‘div id=”loading”img src=”img/loading.gif” alt=”修改中…”//div’;
11 $(this).parent().append(loading);
12 $(‘#loading’)
13 .css({
14 “color” : “red” ,
15 “display” : “none”
16 })
17//定義ajax的全局事件
18 $(this).ajaxStart(function(){
19 $(‘#loading’).show();
20 })
21 $(this).ajaxStop(function(){
22 $(‘#loading’).remove();
23 })
24
25 $(“.listorder_input”).blur(function(){
26 var thislist = $(this).siblings(); //取得同級的標籤 即 修改後需要顯示的 listorder
27 $.post(“ajax.php”,{
28 action : “mod_listorder”,
29 catid : catid ,
30 listorder : $(this).attr(“value”)
31 } , function(data, textStatus){
32 $(thislist).text(data);
33 }
34 );//end .post
35 $(this).remove();
36 })//end function blur
37})// end function click
ajax.php中內容就簡單了,我只是做了處理做演示用,並沒有向伺服器提交數據,代碼如下:
1sleep(1);//延時運行1秒,查看效果用,實際代碼中不需要
2echo $_POST[‘listorder’];
求一個PHP代碼
?php
$con = mysql_connect(“localhost”,”root”,”123456″);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}
else
{
header(“Location:login.php”)
}
?
求一個PHP資料庫模糊搜索帶分頁的代碼
script type=”text/javascript”if(window.location.toString().indexOf(‘pref=padindex’) != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf(“?mobile”)0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href=”{dede:global.cfg_mobileurl/}/list.php?tid={dede:field.id/}”;}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}/script
!–[if IE 6]
script type=”text/javascript” src=”/skin/js/png.js”/script
scriptDD_belatedPNG.fix(‘div,img,span,li,a,a:hover,dd,p,input,select’)/script
![endif]–
script type=”text/javascript”
$(function(){
//一次縱向滾動一個
$(‘#marquee2’).kxbdSuperMarquee({
distance:30,
time:3,
btnGo:{up:’#goU’,down:’#goD’},
direction:’up’
});
});
/script
script type=”text/javascript”
window.onload = function(){
imgZoomRun(“product3″,”p”,”prod-zoom”,”li”); // 圖片放大
imgZoomRun(“product7″,”p”,”prod-zoom”,”li”);
imgZoomRun(“product8″,”p”,”prod-zoom”,”li”);
newsFontMove(“fontjump”); // 滑鼠放上,字體上下挪
newsFontMove(“fontjumpcolor”); // 滑鼠放上,字體上下挪
colorChange(“fontjumpcolor”); // 隔行換色
colorChange(“news5”); // 隔行換色
listImgZoom(“product3″,”205”); // 圖片縮放,需要給定寬度
enterAnimation(“news_fadein”);
if(typeof(data) != “undefined”){
var lefttype = new LeftType(data,”left-type”,0); // 多級分類
}
afx.conHeightAuto();
};
window.addEventListener(“resize”,function(){
afx.conHeightAuto();
},false);
/script
link rel=”stylesheet” type=”text/css” href=”/skin/css/child_page.css” /
script type=”text/javascript” src=””/script
/head
body
?php include_once(“baidu_js_push.php”) ?
!– 頭部 —
{dede:include filename=”head.htm”/}
!– 頭部 end —
div class=”main_c”
div class=”main” id=”content”
!– 左側部分 —
{dede:include filename=”left.htm”/}
!– 左側部分 end–
!– 內容部分 —
div class=”sp_content” id=”contentRight”
div class=”content_com_title”
h2{dede:field name=’typename’/}/h2
div class=”bread” 當前位置:搜索 strong class=”fc_03c”{dede:global name=’keyword’ function=’RemoveXSS(@me)’/}/strong 的結果 /div
/div
div class=”content”
ul class=”news1 news3 news_indent” id=””
{dede:list pagesize =’15’}
li a href=”[field:arcurl/]” title=”[field:title/]” class=”pg-color”[field:title/]/a span[field:pubdate function=”MyDate(‘Y-m-d’,@me)”/]/span /li
{/dede:list}
/ul
div class=”pagexx”
ul
{dede:pagelist listitem=”info,index,end,pre,next,pageno” listsize=”5″/}
/ul
/div
/div
/div
!– 內容部分 end–
這是我網站,你看看能用嗎?
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/195754.html