急急急 很简单的函数调用问题 求大家来指导 JS新手
本帖最后由 u010354801 于 2013-06-28 09:55:49 编辑
jQuery(function(){
$j(".toupiaobtn .btn1, .toupiaobtn.btn2").click(function(e){
注意这里 两个按钮 第一个按钮 调用下面这个函数my_alert 第二个按钮
也是需要调用这个函数 但是出现的CSS界面是不一样的
我已经写好了CSS 但是不知道两个按钮如何调用用一个函数 显示不同的弹出框
求解
myvote();
});
$j('#yzm').click(function(e){this.src='includes/rand_func.php?rc='+Math.random();});
});
function my_alert(i,values){ //调用这里 下面这个函数有判断 求解
var x=$j(document).height();
var y=$j(window).width();
$j(".hide").show();
$j(".close").show();
$j(".haha").css({height:x+"px",display:"block",right:y+"px"}).animate({right:"0"},400);
$j(".hide").animate({top:"30%"},1000,function(){$j(this).animate({top:"20%"},500,function(){$j(this).animate({top:"25%"},1000)
})
});
if(i==0){
$j(".tishi").text(values);
$j(".no,.sures,.xinxi").show();
}else{
$j(".tishi").text(values);
$j(".yes,.sure,.xinxis").show();
}
}
function myvote()
{
<?php
$ip=getip();
$total_votes = '0';
$vtime = '0000000000';
//查询某IP当天投票总数
//查询24小时: WHERE UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(add_time)<=86400
$sql="select sum(votes) as total_votes from ".$dbtablepre."voterec where date(FROM_UNIXTIME(vtime))=CURDATE() and ip='$ip'";
$db->query($sql);
$tmp_rs=$db->fetchRow();
if( $tmp_rs && is_numeric($tmp_rs['total_votes']) && $tmp_rs['total_votes'] > 0)
{
$total_votes = $tmp_rs['total_votes'];
}
//var_dump($total_votes);
//查询某IP最后投票记录
//查询24小时: WHERE UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(add_time)<=86400
$sql="select vtime from ".$dbtablepre."voterec where ip='$ip'";
$db->query($sql);
$tmp_rs=$db->fetchRow();
if( $tmp_rs )
{
$vtime = $tmp_rs['vtime'];
}
?>
var url = 'ajax.php';
var user='<?php if(!empty($username)) echo $username;else echo '';?>';
var nowtime= <?php echo $vtime . $total_votes;?>;
<?php
if($config['isloginv']==0)
{
?>
if(user=='')
{
alert('登陆以后才可以投票!请先登陆,或者花30秒注册新的用户');
window.location.href='<?php if(!empty($bbsconfig["bbs"]) && $bbsconfig["bbs_user_type"]=="2") echo $bbsconfig["bbslogourl"]."&referer=http://".$_SERVER ["HTTP_HOST"].$_SERVER["REQUEST_URI"];else echo $weburl."/member/index.php";?>';
return false;
}
<?php
}
if($config["codetype"]!=99)
{
?>
var ecode=document.getElementById('randcode').value;
if(ecode=='')
{
my_alert('请输入正确验证码!');
document.getElementById('randcode').focus();
return false;
}
<?php
}
else
echo 'var ecode=9999;
';
?>
var vid='<?php echo $_GET["uid"];?>';
var pars = 'nt='+nowtime+'&user='+user+'&vid='+vid+'&randcode='+ecode+"&time="+new Date().getTime();
//var myAjax = new Ajax.Request(url,{method: 'post', parameters: pars, onComplete: showResponse});
$j.ajax(
url,
{
cache :false,
async :true,
type:'POST',
data:pars,
success:showResponse,
error:function(jqXHR, textStatus,errorThrown){alert(textStatus);}
}
);
function showResponse(data,status,originalRequest)
{
//alert(data);
if(data>99)
{
my_alert(0,'不在投票范围内');
}
else if(data>8)
{
my_alert(0,'请勿重复投票!');
}
else if(data>7)
{
my_alert(0,'请勿重复投票!');
}
else if(data>6)
{
my_alert(0,'你不是投票用户,只有登陆的投票用户才可以投票!参赛选手不可以投票!');
}
else if(data>5)
{
my_alert(0,'请输入正确的验证码!请刷新以后再试一次!');
document.getElementById('randcode').focus();
}
else if(data>4)
{
my_alert(0,'不在投票的时间范围内!');
}
else if(data>3)
{
my_alert(0,'请登陆以后再进行投票!');
window.location.href='index.php';
}
else if (data>2)
{
my_alert(0,'你可能登陆超时了!请重新登陆以后再投票!');
window.location.href='index.php';
}
else if (data>1)
{
my_alert(0,"请勿重复投票!");
}
else if (data>0)
{
//window.location.href='player/voteok.php?voteno=<?php echo $rs['idnum']; ?>';
my_alert(1,'投票成功!');
orig_vote_num += 1;
//document.getElementById('youcanvote').onclick = function('alert("你刚刚投票成功,等一哈再投吧!");');
$j('.shuzis').text(orig_vote_num);
}
else
my_alert(0,'请勿重复投票!');
//document.getElementById('randcode').value='';
<?php if($config['codetype']==1) {?>
//document.getElementById('yzm').setAttribute('src','includes/rand_func.php?rc='+Math.random());
<?php } elseif($config['codetype']==7) {?>
//document.getElementById('yzm').setAttribute('src','includes/num_code.php?rc='+Math.random());
<?php } elseif($config['codetype']==6) {?>
//document.getElementById('yzm').setAttribute('src','includes/crand_code.php?rc='+Math.random());
<?php } ?>
}
}