@seraphi

Как скрывать элементы в зависимости от значения input?

Как при выборе корпуса, скрывать некоторые параметры? Ну и что бы это корректно работа, так как на некоторых может стоять checked.
codepen
<section class="const">
        <h3>Конструктор аппаратов</h3>
        <form id="autoForm" class="calc">
            <div class="calc_item">
                <h4>Корпус</h4>
                <div class="calc_block">
                    <input id="corps_desb" type="radio" name="corps" value="555" checked></input>
                    <label for="corps_desb">Daisy, EOS, Smart, Blossom</label>
                </div>
                <div class="calc_block">
                    <input id="corps_porto" type="radio" name="corps" value="666"></input>
                    <label for="corps_porto">Porto</label>
                </div>
                <div class="calc_block">
                    <input id="corps_galaxy" type="radio" name="corps" value="777"></input>
                    <label for="corps_galaxy">Galaxy</label>
                </div>
                <div class="calc_block">
                    <input id="corps_hunter" type="radio" name="corps" value="888"></input>
                    <label for="corps_hunter">Hunter</label>
                </div>
            </div>
            <div class="calc_item">
                <h4>Мощьность</h4>
                <div class="calc_block">
                    <input id="power1" type="radio" name="power" value="555" checked></input>
                    <label for="power1">600W</label>
                </div>
                <div class="calc_block">
                    <input id="power2" type="radio" name="power" value="666"></input>
                    <label for="power2">800W</label>
                </div>
                <div class="calc_block">
                    <input id="power3" type="radio" name="power" value="777"></input>
                    <label for="power3">1000W</label>
                </div>
                <div class="calc_block">
                    <input id="power4" type="radio" name="power" value="888"></input>
                    <label for="power4">1200W</label>
                </div>
            </div>
            <div class="calc_item">
                <h4>Длина волны</h4>
                <div class="calc_block">
                    <input id="wave1" type="radio" name="wave" value="555" checked></input>
                    <label for="wave1">808</label>
                </div>
                <div class="calc_block">
                    <input id="wave2" type="radio" name="wave" value="666"></input>
                    <label for="wave2">808+755</label>
                </div>
                <div class="calc_block">
                    <input id="wave3" type="radio" name="wave" value="777"></input>
                    <label for="wave3">808+755+1064</label>
                </div>
            </div>
            <div class="calc_item">
                <h4>Цвет</h4>
                <div class="calc_block">
                    <input id="white" type="radio" name="color" value="0" checked></input>
                    <label for="white">белый</label>
                </div>
                <div class="calc_block">
                    <input id="white_blue1" type="radio" name="color" value="0"></input>
                    <label for="white_blue1">белый/синий</label>
                </div>
                <div class="calc_block">
                    <input id="white_blue2" type="radio" name="color" value="0"></input>
                    <label for="white_blue2">белый/голубой</label>
                </div>
                <div class="calc_block">
                    <input id="white_red" type="radio" name="color" value="0"></input>
                    <label for="white_red">белый/красный</label>
                </div>
                <div class="calc_block">
                    <input id="white_green" type="radio" name="color" value="0"></input>
                    <label for="white_green">белый/зеленый</label>
                </div>
                <div class="calc_block">
                    <input id="white_purple" type="radio" name="color" value="0"></input>
                    <label for="white_purple">белый/фиолетовый</label>
                </div>
            </div>
            <div class="calc_item">
                <h4>Логотип</h4>
                <div class="calc_block">
                    <input id="logotype1" type="radio" name="logotype" value="555" checked></input>
                    <label for="logotype1">Да</label>
                </div>
                <div class="calc_block">
                    <input id="logotype2" type="radio" name="logotype" value="0"></input>
                    <label for="logotype2">Нет</label>
                </div>
            </div>
            <div class="calc_item">
                <h4>Охлаждение</h4>
                <div class="calc_block">
                    <input id="pump-action" type="radio" name="cooling" value="555" checked></input>
                    <label for="pump-action">Помповое охлаждение</label>
                </div>
                <div class="calc_block">
                    <input id="hitachi" type="radio" name="cooling" value="666"></input>
                    <label for="hitachi">Компрессор Hitachi</label>
                </div>
                <div class="calc_block">
                    <input id="panasonic" type="radio" name="cooling" value="777"></input>
                    <label for="panasonic">Компрессор Panasonic</label>
                </div>
            </div>
            <div class="calc_item">
                <h4>Диод</h4>
                <div class="calc_block">
                    <input id="diode1" type="radio" name="diode" value="555" checked></input>
                    <label for="diode1">50A</label>
                </div>
                <div class="calc_block">
                    <input id="diode2" type="radio" name="diode" value="666"></input>
                    <label for="diode2">100A</label>
                </div>
            </div>
            <div class="calc_item">
                <h4>Размер пятна</h4>
                <div class="calc_block">
                    <input id="spot1" type="radio" name="spot" value="555" checked></input>
                    <label for="spot1">11*11</label>
                </div>
                <div class="calc_block">
                    <input id="spot2" type="radio" name="spot" value="666"></input>
                    <label for="spot2">10*18</label>
                </div>
                <div class="calc_block">
                    <input id="spot3" type="radio" name="spot" value="777"></input>
                    <label for="spot3">15*25</label>
                </div>
                <div class="calc_block">
                    <input id="spot4" type="radio" name="spot" value="888"></input>
                    <label for="spot4">20*30</label>
                </div>
            </div>
        </form>
        <div class="mpdel-summary">
            <div class="model-price" id="modelPrice"></div>
        </div>
    </section>

var modelPrice,
    modelPriceHolder;

    modelPriceHolder = $('#modelPrice');
    
    modelPrice = 0;

    function calculatePrice(){

        var modelPriceCorps = $('input[name=corps]:checked', '#autoForm').val();
        var modelPricePower = $('input[name=power]:checked', '#autoForm').val();
        var modelPriceWave = $('input[name=wave]:checked', '#autoForm').val();
        var modelPriceColor = $('input[name=color]:checked', '#autoForm').val();
        var modelPriceLogotype = $('input[name=logotype]:checked', '#autoForm').val();
        var modelPriceCooling = $('input[name=cooling]:checked', '#autoForm').val();
        var modelPriceDiode = $('input[name=diode]:checked', '#autoForm').val();
        var modelPriceSpot = $('input[name=spot]:checked', '#autoForm').val();

        modelPriceCorps = parseInt(modelPriceCorps);
        modelPricePower = parseInt(modelPricePower);
        modelPriceWave = parseInt(modelPriceWave);
        modelPriceColor = parseInt(modelPriceColor);
        modelPriceLogotype = parseInt(modelPriceLogotype);
        modelPriceCooling = parseInt(modelPriceCooling);
        modelPriceDiode = parseInt(modelPriceDiode);
        modelPriceSpot = parseInt(modelPriceSpot);

        modelPrice = modelPriceCorps + modelPricePower + modelPriceWave + modelPriceColor + modelPriceLogotype + modelPriceCooling + modelPriceDiode + modelPriceSpot;

        modelPriceHolder.text(modelPrice + ' $');

    };

    $('#autoForm input').on('change', function(){
        calculatePrice();
    });
    calculatePrice();
  • Вопрос задан
  • 87 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы