码迷,mamicode.com
首页 > Web开发 > 详细

js写的体彩足球预测分析

时间:2014-07-03 09:11:15      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   width   文件   os   

最近室友在玩世界杯的预测,我顺手写点分析;下面直接给出代码,很简单的,拷贝代码直接存为html文件就可以了。---------mq0036

说明下:需要你自己去找个Jquery引用到当前页面就可以了

<html>
<head>

<script src="jquery-1.4.2.min.js"></script>

<script>

function js()
{
    //$("tr").children("td")[3].css("background-color","red");
    //$("#td1").css("background-color","#516831");
    
    var a=b=c=0;
    
    a=$("#z").val();
    b=$("#k").val();
    c=$("#r").val();
    
    $("#rqs").html(c);
    
    if(a>b)setcolor("td1");
    if(a==b)setcolor("td2");
    if(a<b)setcolor("td3");
    
    if(a+c>b)setcolor("rtd1");
    if(a+c==b)setcolor("rtd2");
    if(a+c<b)setcolor("rtd3");
}


function setcolor(id){
    $("#"+id).css("background-color","#516831");
}

$("#b1").hide();

function zh(){
    var str="",str2="";
    var a1=0,a2=0,b1=0,b2=0,c=0;
    
    a1=$("#z1").val();
    a2=$("#z2").val();
    b1=$("#k1").val();
    b2=$("#k2").val();
    c=$("#r").val();
    
    $("#chk").html("");
    $("#chk").append(胜<input type=checkbox value=s checked=checked onclick="chk()" /> 负<input checked=checked type=checkbox value=f onclick="chk()"/> 平<input checked=checked type=checkbox value=p onclick="chk()" />);
    $("#chk").append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    $("#chk").append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    $("#chk").append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    $("#chk").append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");

    var spf;
    for(i=a1;i<=a2;i++){
        for(j=b1;j<=b2;j++){
            
            if((1*i)>j)spf="s";
            if((1*i)==j)spf="p";
            if((1*i)<j)spf="f";
            
            str += "<tr class=‘"+spf+"‘><td>"+i+"&nbsp;</td><td>"+j+"&nbsp;</td>";
            if(i>j){str += "<td style=‘background-color:#516831;‘>&nbsp;</td>"}else{str += "<td>&nbsp;</td>";}
            if(i==j){str += "<td style=‘background-color:#516831;‘>&nbsp;</td>"}else{str += "<td>&nbsp;</td>";}
            if(i<j){str += "<td style=‘background-color:#516831;‘>&nbsp;</td>"}else{str += "<td>&nbsp;</td>";}
            str += "<td>&nbsp;"+c+"</td>";
            
            //alert("i="+i+" j="+j+","+(1*i+c*1)+"\n(i+c)>j :" +((i+c)>j));
            if((1*i+c*1)>j){str += "<td style=‘background-color:#516831;‘>&nbsp;</td>"}else{str += "<td>&nbsp;</td>";}
            if((1*i+c*1)==j){str += "<td style=‘background-color:#516831;‘>&nbsp;</td>"}else{str += "<td>&nbsp;</td>";}
            if((1*i+c*1)<j){str += "<td style=‘background-color:#516831;‘>&nbsp;</td>"}else{str += "<td>&nbsp;</td>";}
            str+="</tr>";
            
            
            
            str2 += "<tr id=‘1_"+i+j+"‘ class=‘"+spf+"2‘><td  rowspan=‘2‘>"+i+"&nbsp;</td><td rowspan=‘2‘>"+j+"&nbsp;</td><td>0</td>";
            if(i>j){str2 += "<td style=‘background-color:#516831;‘>&nbsp;</td>"}else{str2 += "<td>&nbsp;</td>";}
            if(i==j){str2 += "<td style=‘background-color:#516831;‘>&nbsp;</td>"}else{str2 += "<td>&nbsp;</td>";}
            if(i<j){str2 += "<td style=‘background-color:#516831;‘>&nbsp;</td>"}else{str2 += "<td>&nbsp;</td>";}
            str2 += "</tr><tr  id=‘2_"+i+j+"‘ class=‘"+spf+"2‘>";
            str2 += "<td>&nbsp;"+c+"</td>";
            if((1*i+c*1)>j){str2 += "<td style=‘background-color:#516831;‘>&nbsp;</td>"}else{str2 += "<td>&nbsp;</td>";}
            if((1*i+c*1)==j){str2 += "<td style=‘background-color:#516831;‘>&nbsp;</td>"}else{str2 += "<td>&nbsp;</td>";}
            if((1*i+c*1)<j){str2 += "<td style=‘background-color:#516831;‘>&nbsp;</td>"}else{str2 += "<td>&nbsp;</td>";}
            str2+="</tr>";
            
            $("#chk").append(i+":"+j+"<input id="+i+j+" type=checkbox i="+i+"   j="+j+" checked onclick=‘chk()‘ /> &nbsp;");
        }
    }
    
    
    $("#pp1").html("");
    $("#pp2").html("");
    $("#pp1").append(str);
    $("#pp2").append(str2);
    
    $(input[type="checkbox"]:checked).each(
                function() {
                    $(this).attr("checked","true");
                }
            );
}



function chk()
{
$(".s").hide();
$(".p").hide();
$(".f").hide();

$(".s2").hide();
$(".p2").hide();
$(".f2").hide();

//$("#s3").hide();
//$("#p3").hide();
//$("#f3").hide();

//$(".sh").hide();


$(input[type="checkbox"]:checked).each(
                function() {
                       $("."+$(this).val()).show(); 
                       //alert($(this).attr("i")+$(this).attr("i"));
                       //alert($(this).attr("id"));
                       //$("."+$(this).val()+"2").show(); 
                       $("#1_"+$(this).attr("i")+$(this).attr("j")).show(); 
                       $("#2_"+$(this).attr("i")+$(this).attr("j")).show(); 
                }
            );
}



</script>




</head>
<body>
主队:<input id=‘z‘ type=text /> 客队:<input id=‘k‘ type=text />
让球:<input id=‘r‘ type=text value="-1" />

<button id=‘b1‘ style="display:none"  onclick="js();">计算</button>
<br />
主队:从<input id=‘z1‘ type=text style="width:40px" value="0" /><input id=‘z2‘ value="2" type=text style="width:40px" >&nbsp;&nbsp;
客队:从<input id=‘k1‘ type=text style="width:40px"  value="0"/><input id=‘k2‘ value="2" type=text style="width:40px" >
<button id=‘b1‘ onclick="zh();">计算所有组合</button>
<button id=‘b1‘ onclick="alert($(‘#sc‘).html());">计算所有组合</button>
<br /><br />
<div id=‘chk‘><input type=checkbox value=s onclick="chk()" /><input type=checkbox value=f onclick="chk()"/><input type=checkbox value=p onclick="chk()" />
</div>
<br />

<table id=‘tab‘>
    <tr>
        <th class="fs16 br0" colspan="2">对阵</th>
        <th class="fs16 br0" colspan="3">胜平负</th>
        <th class="fs16" colspan="4">让球胜平负</th>
    </tr>
    <tr>
        <th class="t1 bt0">主队</th>
        <th class="t1 br0 bt0">客队</th>
        <th class="t3 br1 bt0">主胜</th>
        <th class="t3 br1 bt0">平局</th>
        <th class="t3 br0 bt0">主负</th>
        <th class="t3 br1 bt0 concede">让球</th>
        <th class="t3 br1 bt0">主胜</th>
        <th class="t3 br1 bt0">平局</th>
        <th class="t3 br0 bt0">主负</th>
    </tr>
    <tbody id="pp1">
    <tr>
        <td>主队</td>
        <td>客队</td>
        <td id=td1>&nbsp;</td>
        <td id=td2>&nbsp;</td>
        <td id=td3>&nbsp;</td>
        <td id=rqs>&nbsp;</td>
        <td id=rtd1>&nbsp;</td>
        <td id=rtd2>&nbsp;</td>
        <td id=rtd3>&nbsp;</td>
    </tr>
    </tbody>
</table>

<br /><br />

<table id=‘tab2‘ style="width:300px;left:450px;">
    <tr>
        <th class="fs16 br0" colspan="2">对阵</th>
        <th class="fs16" colspan="4">让球胜平负</th>
    </tr>
    <tr>
        <th class="t1 bt0">主队</th>
        <th class="t1 br0">客队</th>
        <th class="t3 br1 bt0 concede">让球</th>
        <th class="t3 br1 bt0">主胜</th>
        <th class="t3 br1 bt0">平局</th>
        <th class="t3 br0 bt0">主负</th>
    </tr>
    <tbody id="pp2">
    <tr class=sh>
        <td rowspan="2">主队</td>
        <td rowspan="2">客队</td>
        <td id=td1>&nbsp;</td>
        <td id=td2>&nbsp;</td>
        <td id=td3>&nbsp;</td>
        <td id=td3>&nbsp;</td>
    </tr>
    <tr class=sh>
        <td id=rqs>&nbsp;</td>
        <td id=rtd1>&nbsp;</td>
        <td id=rtd2>&nbsp;</td>
        <td id=rtd3>&nbsp;</td>
    </tr>
    </tbody>
</table>


</body>
</html>


<style>

table
{    border-width:1px;
    border-color:#f00;
    border-style:solid;
    text-align:center;
    font-Size:12px;
    width:400px;
    position: absolute;
    top:110px;
}
th{
    border-width:thin;
    border-color:#f00;
    border-style:solid;
    height:25px;
}

td
{    border-width:1px;
    border-color:#f00;
    border-style:solid;
    text-align:center;
    font-Size:12px;
}

</style>

 

js写的体彩足球预测分析,布布扣,bubuko.com

js写的体彩足球预测分析

标签:style   blog   color   width   文件   os   

原文地址:http://www.cnblogs.com/mq0036/p/3818330.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!