function myprint(){
count++//计数
//其它逻辑
}
var count = 0document.onclick = function(){
count++
alert(count)
}
用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
}
?>