teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

追記

2016/04/08 02:02

投稿

hidepon
hidepon

スコア206

title CHANGED
File without changes
body CHANGED
@@ -24,4 +24,46 @@
24
24
  });
25
25
 
26
26
 
27
+ ```
28
+ 追記
29
+
30
+ ```
31
+ <table id="pt2" border="1" class="table ap_table">
32
+ <tbody>
33
+ <tr>
34
+ <th>実施日2</th>
35
+ <td>
36
+ <input type="text" id="target_year2" name="target_year2" size="4" maxlength="4" class="inp" value="<?php echo $target_year;?>" />年
37
+ <input type="text" id="target_month2" name="target_month2" size="2" maxlength="2" class="inp" value="<?php echo $target_month;?>" />月
38
+ <input type="text" id="target_day2" name="target_day2" size="2" maxlength="2" class="inp" value="<?php echo $target_day;?>" />日
39
+ <input type="button" id="dp_pos2" name="dp_pos2" value="日付選択" />
40
+ <input type='hidden' id='container' />
41
+ </td>
42
+ </tr>
43
+ </tbody>
44
+ </table>
45
+ <div id='dpbody' style='position:absolute;left:200px'></div>
46
+ //JS
47
+ $('#container').datepicker({
48
+ language : ja,
49
+ clearBtn : true,
50
+ container : '#dpbody'
51
+ }).on('changeDate', function(){
52
+ if(e.date){
53
+ var d = e.date;
54
+ $('#target_year2').val( d.getFullYear() );
55
+ $('#target_month2')val( d.getMonth() + 1 );
56
+ $('#target_day2').val( d.getDate());
57
+ }
58
+ $(this).datepicker('hide')
59
+ });
60
+ $('#dp_pos2').on('click', function(){
61
+ $('#container').datepicker('show').on( 'changeDate', function( e ) {
62
+ $('#target_year2').val( e.date.getFullYear() );
63
+ $('#target_month2').val( e.date.getMonth() + 1 );
64
+ $('#target_day2').val( e.date.getDate());
65
+ $(this).datepicker('hide')
66
+ });
67
+ });
68
+
27
69
  ```