0
사용자가 드롭 다운 선택을 변경하면 일부 PHP 계산을 수행하는 아약스 설정이 있습니다. 그런 다음 결과를 다시 전송하여 출력합니다. 이 기능은 사용자가 처음으로 화면을로드 할 때 빈 결과 상자 만 사용하고 드롭 다운 상자 중 하나에서 선택 항목을 변경할 때만 결과가 나타납니다. 내 질문은, 어쨌든 창이로드 될 때 아약스를 실행하는, 그래서 기본 드롭 다운 선택 ouputed 수 있습니다. 여기 창이 처음로드 될 때 onchange ajax 실행
는 Ajax 코드, 당신은 아무것도 필요하면 알려 : 그것은 당신의 변화를 트리거<script>
$("document").ready(function(){
$(".add_detail_dropdown").change(function(){
var m = document.getElementById('meter_square');
var meter_square = m.options[m.selectedIndex].value;
var s = document.getElementById('story_height');
var story_height = s.options[s.selectedIndex].value;
var r = document.getElementById('roof_type');
var roof_type = r.options[r.selectedIndex].value;
var q = document.getElementById('material_quality');
var material_quality = q.options[q.selectedIndex].value;
var w = document.getElementById('wall_type');
var wall_type = w.options[w.selectedIndex].value;
var f = document.getElementById('flooring');
var flooring = f.options[f.selectedIndex].value;
$.ajax({
type: "GET",
url: "add_extension_calc.php",
data: { meter_square: meter_square, story_height: story_height, roof_type: roof_type, material_quality: material_quality, wall_type: wall_type, flooring: flooring, estimated_wealth: <?php print "$estimated_wealth";?>, gain_percent: <?php print "$addon_gain_percent";?> },
dataType: "json",
statusCode: {
200: function (response) {
$("#res_expected_gain").html(response.total_gain);
$("#res_expected_house_price").html(response.house_price);
$("#res_total_supply_cost").html(response.store_price);
$("#res_total_supply_time").html(response.store_time);
$("#res_expected_profit").html(response.expected_profit);
}
}
});
})
});
</script>
는 일 그 화려한 확인 할 수 나는 전에 그것에 대해 생각하지 않았다고 생각하지 않는다. 도와 주셔서 감사합니다 – Arken