테스트 사이트 - 개발 중인 베타 버전입니다

비용산출 php좀 알려주세요 채택완료

zkdlf 7년 전 조회 3,631

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

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

</strong></p>

<p><table class="mt10" width="95%" cellspacing="0" cellpadding="0" align="center">

    <tbody>

    <tr class="tableTtx">

    <td>물품비용</td>



    <td>수량</td>



    <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></p>

<p><strong>

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트
mkdir
7년 전

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>
 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 4개

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

[code]
<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>
[/code]
m
mkdir
7년 전
잘하셨는데 한개 실수하셨네요 #Test input을 제가 선언했는데



이건 테이블에 id="Test"를 추가했었답니다 확인해보세요~
z
zkdlf
7년 전
오감사합니다. 작동됩니다.

수고하십시요
m
mkdir
7년 전
onsole.log()를 실수로 안 지웠네요 ㅋㅋ 이거 테스트용이니 지우셔야합니다 ㅋㅋ

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인