Home >Backend Development >PHP Tutorial >php基础+jquery基础

php基础+jquery基础

WBOY
WBOYOriginal
2016-06-23 14:00:55896browse

1.编写一个函数,使它可以根据传入的2个年周号,返回它们之间的周数(包括传入的这两周)


2.用JQuery实现根据所选的日期范围动态增加那范围内每一天的金额输入框,并在最后面显示出所有天金额的累加值


回复讨论(解决方案)

1.

function between($one,$tow){	return abs(date('W',$one) - date('W',$two));}

2.

<html>    <head>        <title>Demo</title>        <script type="text/javascript" src="jquery-1.4.2.min.js"></script>    </head>     <body>            <input type="text" id="time" value="2014/01/01-2014/01/10">            <div id="timeShow"></div>            <span id='countSpan'></span>            <input type="button" value="结算" id='count'>            <script type="text/javascript">            $(function(){//jquery开始 必不可少                                 var time = $("#time").val();                 var timeArr = time.split('-');                 var date1 = new Date(timeArr[0]);                 var date2 = new Date(timeArr[1]);                 var miao = Math.abs(date2.getTime() - date1.getTime());                 var day = parseInt(miao / (1000 * 60 * 60 * 24));//计算相差天数                 var input = '';                 for(var i=0;i<=day;i++){                    input += '<input type="text" id="day_'+i+'" class="day">';                 }                 $("#timeShow").html(input);                 $("#count").click(function(){                    var total = 0;                    $(".day").each(function(){                        var val = $(this).val();                        val = $.trim(val);                        val = isNaN(val) || val == "" ? 0 : val;                        total += parseFloat(val);                    })                    $("#countSpan").html(total);                 })                             })                    </script>    </body></html>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn