비용산출 php좀 알려주세요

비용산출 php좀 알려주세요

QA

비용산출 php좀 알려주세요

본문

물품비용하고 수량을 입력하면 자동으로 비용합계가 나오고

비용합계와 지정된 Commission(%)가 총결제비용이 자동으로 산출할려면 어떻게 해야하나요?


<table class="mt10" width="95%" cellspacing="0" cellpadding="0" align="center">
    <tbody>
    <tr class="tableTtx">
    <td>물품비용</td><br><br>
    <td>수량</td><br><br>
    <td>비용합계</td>
    <td>Commission(%)</td>
    <td>총 결제 비용</td>
    </tr>
    <tr class="tableTtx">
    <td>
    <input class="input_style3 txc" id="iPrice_i" name="iPrice_i" type="text">
    <select class="select_style2" id="sPriceType_i" name="sPriceType_i">
    <option value="won">won</option>
    </select>
    </td>
    <td><input class="input_style10 txc" id="iCommission_i" name="iCommission_i" onblur="fnCalc()" type="text"></td>
    <td>
    <input class="input_style3 txc" id="iFee_i" name="iFee_i" type="text">
    <select class="select_style2" id="sPriceType_i" name="sPriceType_i">
    <option value="won">won</option>
    </td>
    <td>
    <input class="input_style3 txc" id="iFee_i" name="iFee_i" type="text">
    </td>
    <td>
    <input class="input_style3 txc" id="iFee_i" name="iFee_i" type="text">
    <select class="select_style2" id="sPriceType_i" name="sPriceType_i">
    <option value="won">won</option>
    </td>
    </tr>
    </tbody></table>

이 질문에 댓글 쓰기 :

답변 1

100% 짜드리지는 않겠습니다.. 실력이 늘지 않거든요

 

물품비용 * 수량 = 비용합계

 

거기에 커미션 %에 따라서 총결제비용 = 비용합계 - (비용합계 * 커미션)

 

확인 해보세요

 

<script>
var calculation = function() {
    var price1 = $('input[name=price1]'); // 물품비용
    var price2 = $('input[name=price2]'); // 수량
    var price3 = $('input[name=price3]'); // 비용합계
    var price4 = $('input[name=price4]'); // 커미션
    var price5 = $('input[name=price5]'); // 총 결제 비용

    console.log(price1.val());
    console.log(price2.val());

    price3.val(parseInt(price1.val()) * parseInt(price2.val())); // 비용합계 넣기

    // 퍼미션 입력받으면 제외하고 총 결제 비용 넣기
    var price3_price = parseInt(price3.val());
    var price4_per = parseFloat('0.'+price4.val());

    price5.val(price3_price - (price3_price * price4_per));
};

$(function(){
    $('#Test input').keyup(function(){
        calculation();
    });
});
</script>
 

감사합니다. 제가 스크립트는 요즘 공부중이라 각 name에다가 price 1~5를 다 적용했는데 작동이안되는데... 이것만 알려주시면 안될까요?


	<tbody>
	<tr class="tableTtx">
	<td>물품비용</td><br><br>
	<td>수량</td><br><br>
	<td>비용합계</td>
	<td>Commission(%)</td>
	<td>총 결제 비용</td>
	</tr>
	<tr class="tableTtx">
	<td>
	<input class="input_style3 txc" id="Test input" name="price1" type="text">
	<select class="select_style2" id="sPriceType_i" name="sPriceType_i">
	<option value="won">won</option>
	</select>
	</td>
	<td><input class="input_style10 txc" id="Test input" name="price2" onblur="fnCalc()" type="text"></td>
	<td>
	<input class="input_style3 txc" id="Test input" name="price3" type="text">
	<select class="select_style2" id="sPriceType_i" name="sPriceType_i">
	<option value="won">won</option>
	</td>
	<td>
	<input class="input_style3 txc" id="Test input" name="price4" type="text">
	</td>
	<td>
	<input class="input_style3 txc" id="Test input" name="price5" type="text">
	<select class="select_style2" id="sPriceType_i" name="sPriceType_i">
	<option value="won">won</option>
	</td>
	</tr>
    </tbody></table>
							
	<!-- 버튼 -->
	<!-- <div class="txr mt20" style="width:98%;"><a href="#" class="button_small orange">전체수정</a></div> -->
    <!-- Paging -->
    </form></div>
	</div>
	</td>
</tr>
</tbody></table>
<script>
var calculation = function() {
    var price1 = $('input[name=price1]'); // 물품비용
    var price2 = $('input[name=price2]'); // 수량
    var price3 = $('input[name=price3]'); // 비용합계
    var price4 = $('input[name=price4]'); // 커미션
    var price5 = $('input[name=price5]'); // 총 결제 비용
    console.log(price1.val());
    console.log(price2.val());
    price3.val(parseInt(price1.val()) * parseInt(price2.val())); // 비용합계 넣기
    // 퍼미션 입력받으면 제외하고 총 결제 비용 넣기
    var price3_price = parseInt(price3.val());
    var price4_per = parseFloat('0.'+price4.val());
    price5.val(price3_price - (price3_price * price4_per));
};
$(function(){
    $('#Test input').keyup(function(){
        calculation();
    });
});
</script>

답변을 작성하시기 전에 로그인 해주세요.
전체 158
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT