$(function() { $("#picture_file").bind("change",this, function(e){ $("form#preview").submit(); } ); $("form#preview").ajaxForm( function(data,status){ $("input#picture_path").val(data); $("img#preview_img").get(0).src = ''+data; } ); $("select[@name=birthYear]").change(function() { setVisibleActIntensityByAge(); }); $("input[@name='sexKbn']").click(function() { setVisibleFemaleInfo(); }); $("input[@name='actIntensityKbn']").click(function() { setVisibleActOther(); }); setVisibleActOther(); setVisibleActIntensityByAge() setVisibleFemaleInfo(); } ); function setVisibleFemaleInfo(){ if($("input[@name='sexKbn']").val() == "01"){ setVisibleRadio("l_pregnantKbn", false); setVisibleRadio("l_jyunyuKbn", false); setVisibleRadio("l_mensKbn", false); }else if(getAge()<8||getAge()>69){ setVisibleRadio("l_pregnantKbn", false); setVisibleRadio("l_jyunyuKbn", false); setVisibleRadio("l_mensKbn", false); }else{ setVisibleRadio("l_pregnantKbn", true); setVisibleRadio("l_jyunyuKbn", true); setVisibleRadio("l_mensKbn", true); } } function setVisibleActOther(){ if($("input[@name='actIntensityKbn']:checked").val() == "05"){ setVisibleRadio("l_actOther", true); }else{ setVisibleRadio("l_actOther", false); } } //”N—î‚̎擾 function getAge(){ var age=0; var birthYear = $("select[@name=birthYear] option:selected").val(); var birthMonth = $("select[@name=birthMonth] option:selected").val(); var birthDate = $("select[@name=birthDate] option:selected").val(); if(!birthYear){ birthYear = $("input[@name='birthYear']").val(); } if(!birthMonth){ birthMonth = $("input[@name='birthMonth']").val(); } if(!birthDate){ birthDate = $("input[@name='birthDate']").val(); } now = new Date(); y=now.getYear(); m=now.getMonth()+1; d=now.getDate(); if(y<1900) {y=y+1900;} if(m < birthMonth){age=y-birthYear-1} if(m > birthMonth){age=y-birthYear} if(m == birthMonth){ if(d < birthDate){age=y-birthYear-1} else{age=y-birthYear} } return age; } function setVisibleActIntensityByAge() { var age = getAge(); var ageInt = parseInt(age); setVisibleRadio('l_actIntensityKbn_low',isVisibleActIntensity01(ageInt)); setVisibleRadio('l_actIntensityKbn_regular',isVisibleActIntensity03(ageInt)); setVisibleRadio('l_actIntensityKbn_high',isVisibleActIntensity04(ageInt)); } function isVisibleActIntensity01(age){ if(6<=age && age<=7) return true; if(8<=age && age<=9) return true; if(10<=age && age<=11) return true; if(12<=age && age<=14) return true; if(15<=age && age<=17) return true; if(18<=age && age<=29) return true; if(30<=age && age<=49) return true; if(50<=age && age<=69) return true; if(70<=age && age<=999) return true; return false; } function isVisibleActIntensity03(age){ if(1<=age && age<=2) return true; if(3<=age && age<=5) return true; if(6<=age && age<=7) return true; if(8<=age && age<=9) return true; if(10<=age && age<=11) return true; if(12<=age && age<=14) return true; if(15<=age && age<=17) return true; if(18<=age && age<=29) return true; if(30<=age && age<=49) return true; if(50<=age && age<=69) return true; if(70<=age && age<=999) return true; return false; } function isVisibleActIntensity04(age){ if(6<=age && age<=7) return true; if(8<=age && age<=9) return true; if(10<=age && age<=11) return true; if(12<=age && age<=14) return true; if(15<=age && age<=17) return true; if(18<=age && age<=29) return true; if(30<=age && age<=49) return true; if(50<=age && age<=69) return true; if(70<=age && age<=999) return true; return false; }