忍者ブログ

カレンダー

02 2024/03 04
S M T W T F S
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

リンク

最新記事

カテゴリー

最新コメント

RSS

ブログ内検索

アーカイブ

[1]  [2]  [3]  [4]  [5]  [6]  [7]  [8

[PR]

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

年月日プルダウンを jsで自動生成する

$(function(){
var now  = new Date();
var year = now.getFullYear();
$('#year_pulldown').append($('<option>').html(year-1).val(year-1));
$('#year_pulldown').append($('<option>').html(year).val(year).attr('selected' , 'selected'));
$('#year_pulldown').append($('<option>').html(year+1).val(year+1));
var month= now.getMonth()+1;
$('#month_pulldown').val(month);
var date = now.getDate();
$('#day_pulldown').val(date);
});

拍手[0回]

PR

date('w')の戻り値

string(1) "4"

string型だよ!

拍手[0回]

mysqli_insert_id

$id = mysqli_insert_id($db);

拍手[0回]

クリックで画像を90度回転

   $(function(){ $('img').click(function(){ var deg = parseInt($('#deg').val()); deg += 90; if (deg >= 360){ deg = 0; } $('img').css("transform" ,"rotate("+String(deg)+"deg)"); $('#deg').val(deg); }); });

拍手[1回]

誕生日⇒年齢

<script type="text/javascript">
function _set(){
// birth[0]→year, birth[1]→month, birth[2]→day
var _birth = parseInt("" + $('#year').val() + affixZero($('#month').val()) + affixZero($('#day').val()) );
var  today = new Date();
var _today = parseInt("" + today.getFullYear() + affixZero(today.getMonth() + 1) + affixZero(today.getDate()));
$('#age').val(parseInt((_today - _birth) / 10000));
}
function affixZero(int) {
if (int < 10) int = "0" + int;
return "" + int;
}
</script>

拍手[0回]



忍者ブログ [PR]

graphics by アンの小箱 * designed by Anne