<input type='button' value='查看当前用户点击次数' onclick='clickShow()' />
function clickCount(){
var UserName = <%=Session["UserName"]%> //aspx页面
var UserInfo = xmlDoc.createElement("UserInfo")
UserInfo.setAttribute("name", UserName)
}
function clickShow(){
var clickCount = 0
var xmlDoc = loadXml("TEST.xml")
for(var i = 0i<xmlDoc.getElementsByTagName("UserInfo").lengthi ++) {
var UserInfo = xmlDoc.getElementsByTagName("UserInfo")[i]
var UserName = UserInfo.getAttribute("UserName")
if(UserName == <%=Session["UserName"]%>){clickCount++}
}
alert("您点击了"+clickCount)
}
function loadXml (xmlFileName) {
var xmlFile = xmlFIleName
if (window.ActiveXObject) {
//IE
xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async = false
xmlDoc.load(xmlFile)
}
else if (document.implementation &&document.implementation.createDocument) {
//其他浏览器
xmlDoc = document.implementation.createDocument('', '', null)
xmlDoc.load(xmlFile)
}
else {
xmlDoc = null
}
return xmlDoc
}
//没测试过 你试试看
用JQ的,ajax 无刷新就能做到了<img src="" id="abc" value="addnum">
<script>
$("#abc").click(function(){
var value = $(this).attr('value')
$.ajax({
type: "POST",
url: "add.php",
data: "type="+value,
success: function(msg){
// alert( "Data Saved: " + msg )
}
})
return false
})
</script>
<?php
/*
*add.php
*参数:type 判断是否是那个图片的点击
*talbe_name 为表名,替换成自己的表名
*/
$type= $_POST['type']
if($type=='addnum'){
$query = mysql_query("upadae talbe_name set num = num +1 where 条件") //执行sql语句
return $query
}
?>