$(document).ready( function() {  var val =$("input[name=freerent]:checked").val();  if(val == 0){    $("#freeStart").attr("disabled","disabled");    $("#freeEnd").attr("disabled","disabled");  }  var val1 =$("input[name=amortize]:checked").val();  if(val1 == 0){    $("#amortizePrice").attr("disabled","disabled");  }  var val2 =$("input[name=insurance]:checked").val();  if(val2 == 0 || val2 == 2){    $("#insuranceTerm").attr("disabled","disabled");    $("#insurancePrice").attr("disabled","disabled");  }  var val3 =$("input[name=payday]:checked").val();  if(val3 == 0){    $("#everyPayday").attr("disabled","disabled");  }});$('[name=freerent]').change( function() {  var val =$(this).val();  if(val != 0){    $("#freeStart").removeAttr("disabled");    $("#freeEnd").removeAttr("disabled");  }else{    $("#freeStart").attr("disabled","disabled");    $("#freeEnd").attr("disabled","disabled");  }});$('[name=amortize]').change( function() {  var val =$(this).val();  if(val != 0){    $("#amortizePrice").removeAttr("disabled");  }else{    $("#amortizePrice").attr("disabled","disabled");  }});$('[name=insurance]').change( function() {  var val =$(this).val();  if(val == 1){    $("#insuranceTerm").removeAttr("disabled");    $("#insurancePrice").removeAttr("disabled");  }else{    $("#insuranceTerm").attr("disabled","disabled");    $("#insurancePrice").attr("disabled","disabled");  }});$('[name=payday]').change( function() {  var val =$(this).val();  if(val == 1){    $("#everyPayday").removeAttr("disabled");  }else{    $("#everyPayday").attr("disabled","disabled");  }});$(function(){  //入居者行を追加する  $(document).on("click", ".rowAdd", function() {    $ ("#liveTable").append(      $("<tr></tr>")      .append($("<td><input type=\"button\" class=\"rowDel btn btn-inverse\" value=\"削除\"></td>"))      .append($("<td><input type=\"text\" name=\"liveName[]\" class=\"form-control\"></td>"))      .append($("<td><input type=\"text\" name=\"liveRelation[]\" class=\"form-control\"></td>"))      .append($("<td><input type=\"text\" name=\"liveTel[]\" class=\"form-control\"></td>"))      .append($("<td><input type=\"text\" name=\"liveYear[]\" class=\"form-control tenant-birth\">年<input type=\"text\" name=\"liveMonth[]\" class=\"form-control tenant-birth\">月<input type=\"text\" name=\"liveDay[]\" class=\"form-control tenant-birth\">日</td>"))    );  });  //行を削除する  $(document).on("click", ".rowDel", function() {    $(this).parent().parent().remove();  });});$(function(){    var count = <?php echo ($data['otherCostCount'] - 1)?>;  //その他費用を追加する  $(document).on("click", ".rowAdd2", function() {      count += 1;    $ ("#otherCostTable").append(      $("<tr></tr>")      .append($("<td><input type=\"button\" class=\"rowDel btn btn-inverse\" value=\"削除\"></td>"))      .append($("<td><select class=\"form-control\" name=\"otherCostKind["+count+"]\"><?php foreach($data['other_income'] as $k => $v):?><option value=\"<?php echo $k?>\"><?php echo $v?></option><?php endforeach;?></select></td>"))      .append($("<td><input type=\"text\" name=\"otherCostName["+count+"]\" class=\"form-control\"></td>"))      .append($("<td><input type=\"text\" name=\"otherCost["+count+"]\" class=\"form-control\"></td>"))      .append($("<td><label for=\"otherCostTax1_"+count+"\"><input type=\"radio\" name=\"otherCostTax["+count+"]\" id=\"otherCostTax1_"+count+"\" value=\"0\" checked>非課税</label><label for=\"otherCostTax2_"+count+"\"><input type=\"radio\" name=\"otherCostTax["+count+"]\" id=\"otherCostTax2_"+count+"\" value=\"1\">別税</label></td>"))      .append($("<td class=\"other-cost-start\"><select name=\"otherCostStartYear["+count+"]\" class=\"form-control year\"><?php for($y=2016;$y>=2010;--$y):?><option value=\"<?php echo $y?>\"<?php if($y==$data['year']){echo 'selected';}?>><?php echo $y?>年</option><?php endfor;?></select><select name=\"otherCostStartMonth["+count+"]\" class=\"form-control month\"><?php for($i=1;$i<=12;++$i):?><option value=\"<?php echo $i?>\"<?php if($i==$data['month']){echo 'selected';}?>><?php echo $i?>月</option><?php endfor;?></select></td>"))    );  });  //行を削除する  $(document).on("click", ".rowDel", function() {    $(this).parent().parent().remove();  });});