js實(shí)現(xiàn)的點(diǎn)擊數(shù)量加一可操作數(shù)據(jù)庫(kù)
更新時(shí)間:2014年05月09日 10:18:57 作者:
這篇文章主要介紹了js如何實(shí)現(xiàn)的點(diǎn)擊數(shù)量加一操作數(shù)據(jù)庫(kù),需要的朋友可以參考下
復(fù)制代碼 代碼如下:
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
String groupId = request.getParameter("groupId");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
<title>寶寶排行榜</title>
<style type="text/css">
body {
text-align: center;
margin: 0 auto;
padding: 0;
background: #ffefe5;
width: 100%;
}
a:link {
text-decoration: none;
}
#static {
margin: 0 auto;
text-align: left;
}
img {
width: 100%;
}
#main {
background: url("../pic/bj_12.jpg") repeat-x;
padding-top: 5px;
}
#main span {
font-size: 1.5em;
color: #2f0075;
margin-left: 40px;
}
#bottom {
width: 100%;
margin: 0;
padding: 0;
font-size: 1em;
}
#bottom ul li {
width: 48%;
float: left;
margin-left: -8%;
margin-right:10%;
list-style-type: none;
}
.sp {
margin-top: -50px;
border-radius: 8px;
}
</style>
<script type="text/javascript">
$(function(){
//動(dòng)態(tài)加載寶貝排行信息
function loadSecondSort() {
$.ajax({
type : "POST",
data : "groupId="+$("#groupId").val(),
url : "<%=basePath%>findBobyRankByVote.action",
success : function(data) {
var list = data.list;
var row = "";
$("ul").empty();
if (list != null && list.length != 0) {
for(var i=0;i<list.length;i++) {
row = "<li><a href=\"bao_x.jsp?id="+list[i].id+"\"> <img src=\"../pic/"+list[i].pic+"\"></a><input type=\"hidden\" id=\"id\" value="+list[i].id+"><div class=\"sp\""+
"style=\"background-color: #ffb7cd; margin-top: 10px; height: 30px\">"+
"<img src=\"../pic/zan.png\" style=\"width: 22px; margin-left: 10px; margin-top: 5px;\" class=\"favour\">"+
"<span style=\"margin-top: 5px; color: #8a7da9; float: right; margin-right: 10px;\">已<span>"+list[i].vote+"</span>票"+
"</span></div></li>";
$(row).appendTo($("ul"));
}
}
}
});
}
$(".favour").live("click",function(){
var id = $(this).closest("li").find("#id").val();
$.post("<%=basePath%>updateBobyRank.action", "id=" + id,
function(data) {
if (data.msg==null){
if (data.success == true) {
loadSecondSort();
}
}else {
alert(data.msg);
}
});
});
window.onload = loadSecondSort();
});
</script>
</head>
<body>
<input type="hidden" id="groupId" value="<%=groupId%>">
<div id="static">
<img src="../pic/top10.jpg"> <a href="../jsp/index.jsp"><img
src="../pic/fan.png" style="width: 10%; margin-top: -50px;"></a>
<div id="main">
<span>近期排名:</span>
</div>
<div id="bottom">
<ul>
</ul>
</div>
</div>
</body>
</html>
相關(guān)文章
JavaScript 保存數(shù)組到Cookie的代碼
大部分的瀏覽器一個(gè)網(wǎng)站只支持保存20個(gè)Cookie,超過(guò)20個(gè)Cookie,舊的Cookie會(huì)被最新的Cookie代替。那么如果要有超過(guò)20個(gè)Cookie要保存只能將Cookie存為數(shù)組然后保存到Cookie。2010-04-04JavaScript三種綁定事件方式及相互之間的區(qū)別分析
這篇文章主要介紹了JavaScript三種綁定事件方式及相互之間的區(qū)別,結(jié)合具體實(shí)例形式分析了javascript事件綁定方式的基本實(shí)現(xiàn)方法與相互之間的區(qū)別,需要的朋友可以參考下2017-01-01全面解析Bootstrap中scrollspy(滾動(dòng)監(jiān)聽(tīng))的使用方法
這篇文章主要為大家全面解析Bootstrap中scrollspy(滾動(dòng)偵聽(tīng))的使用方法,感興趣的小伙伴們可以參考一下2016-06-06getElementByID、createElement、appendChild幾個(gè)DHTML元素
WEB標(biāo)準(zhǔn)下可以通過(guò)getElementById(), getElementsByName(), and getElementsByTagName()訪問(wèn)2008-06-06js拆分字符串并將分割的數(shù)據(jù)放到數(shù)組中的方法
這篇文章主要介紹了js拆分字符串并將分割的數(shù)據(jù)放到數(shù)組中的方法,涉及javascript中split方法及數(shù)組的操作技巧,需要的朋友可以參考下2015-05-05Javascript基于OOP實(shí)實(shí)現(xiàn)探測(cè)器功能代碼實(shí)例
這篇文章主要介紹了Javascript基于OOP實(shí)實(shí)現(xiàn)探測(cè)器功能代碼實(shí)例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-08-08