초짜라 이렇거든요..ㅎ
백만 하나, 백만 둘, 백만 세개를 해야 하는데...너무 무식한거 같아서..
$(document).on("click", function() {
$("#deposit1").change( function() {
jQuery('#deposit_date1').val('<?=G5_TIME_YMD?>');
});
$("#deposit2").change( function() {
jQuery('#deposit_date2').val('<?=G5_TIME_YMD?>');
});
$("#deposit3").change( function() {
jQuery('#deposit_date3').val('<?=G5_TIME_YMD?>');
});
$("#deposit4").change( function() {
jQuery('#deposit_date4').val('<?=G5_TIME_YMD?>');
});
$("#deposit5").change( function() {
jQuery('#deposit_date5').val('<?=G5_TIME_YMD?>');
});
...
....
});
답변 3개 / 댓글 6개
20개라면
$(document).on("click", function() {
for(var i = 1; i <=20; i++) {
$("#deposit"+i).change( function() {
jQuery("#deposit_date"+i).val('<?=G5_TIME_YMD?>');
});
}
});
답변에 대한 댓글 4개
id 말고 class로 하시면 간단히 처리될꺼에요..
<?php for($i=0;$i<10;$i++){?>
<input type="text" name="deposit[]" class="deposit">
<input type="text" name="deposit_date[]" class="deposit_date">
<?php
}
?>
<script type="text/javascript">
<!--
$(document).on("click", function() {
$(".deposit").change( function() {
$(this).next('.deposit_date').val('<?=G5_TIME_YMD?>');
});
});
//-->
</script>
답변을 작성하려면 로그인이 필요합니다.