두 개의 입력이 있는데, 여기서 사용자 유형은 width
과 height
입니다 (단위는 mm입니다). 따라서 최소 가격은 width=50
및 height=20
까지 250 달러입니다. 그런 다음 폭 또는 높이가 10mm 씩 편집 될 때마다 총 가격을 $ 25만큼 올리고 싶습니다. 따라서 총계는 $ 275이어야합니다. w=60 and h=20
(또는 w=50/h=30
); $ - 300 Calc의 가격은 parseInt를 기준으로합니다.
var basePrice = 250;
var priceForSm = 50;
var price300 = basePrice + priceForSm;
var price450 = price300 + (priceForSm * 3);
var price700 = price450 + (priceForSm * 5);
var price950 = price700 + (priceForSm * 5);
$("#stwidth, #stheight").keyup(function() {
\t var stwidth = parseInt($("#stwidth").val(), 10);
\t var stheight = parseInt($("#stheight").val(), 10);
\t if (stwidth > 113) {
\t \t $("#stwidth").val("113");
\t }
if (stheight > 62) {
\t \t $("#stheight").val("62");
\t }
\t if (stwidth >= 50 && stheight >= 20 || stwidth >= 110 && stheight >= 10) {
\t \t $(".stamp-full-price span").html(basePrice);
\t }
\t if (stwidth >= 30 && stheight >= 60 || stwidth == 80 && stheight == 20 || stwidth >= 60 && stheight >= 30 || stwidth >= 40 && stheight >= 40) {
\t \t $(".stamp-full-price span").html(price300);
\t }
\t if (stwidth >= 110 && stheight >= 20 || stwidth >= 110 && stheight == 30 || stwidth >= 70 && stheight >= 30 || stwidth >= 60 && stheight >= 40 || stwidth >= 50 && stheight >= 50 || stwidth >= 40 && stheight >= 60) {
\t \t $(".stamp-full-price span").html(price450);
\t }
\t if (stwidth >= 110 && stheight >= 40 || stwidth >= 110 && stheight >= 50 || stwidth >= 90 && stheight >= 40 || stwidth >= 80 && stheight >= 50 || stwidth >= 60 && stheight >= 60) {
\t \t $(".stamp-full-price span").html(price700);
\t }
\t if (stwidth >= 100 && stheight >= 60 || stwidth >= 111 && stheight >= 50) {
\t \t $(".stamp-full-price span").html(price950);
\t }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" name="stwidth" id="stwidth" value="50" class="form-control input-xs" maxlength="3"> x <input type="text" name="stheight" id="stheight" value="20" class="form-control input-xs" maxlength="2"> мм
<div class="stamp-full-price">
Total: <span>250</span>
</div>
w=60 and h=30
... 여기 가격과 크기를 수동으로 설정,하지만 설정하지 않으
따라서 가격을 width
및 height
으로 따로 조절하는 것이 좋습니다. 또한 케이스의 모든 크기를 다루지 않으므로 특정 상황에서 어떤 가격이 표시 될지 예측할 수 없으며 실제로 괴물입니다. :)
라디오 및 체크 박스 형태의 크기 다음으로 몇 가지 다른 옵션이 있습니다. 그렇다면 라디오/체크 박스의 가격을 추가하기 위해 정의 된 크기 이후 총 가격의 가치를 얻는 방법은 무엇입니까?
이미 너비/높이를 얻을 단지 수학을, 모든 추가 10 $가 25 가격을 증가 할 수있는 방법을 발견하면서
질문에 코드 (바이올린에뿐만 아니라 링크)를 붙여 계산 하나 개 더 솔루션입니다 – happymacarts
가장 좋은 시나리오는 알아낼 차원을 기반으로 가격을 계산해야하는 수식입니다. 그런 다음 이벤트 처리기의 함수에 추가하십시오. – happymacarts
@LukasLiesis, 너무 빨리 읽었습니다. (자러 가고 있습니다!) 스레드를 정리하기 위해 Origt를 삭제합니다. – happymacarts