L
L
labaget2021-06-19 17:05:43
PHP
labaget, 2021-06-19 17:05:43

How to make the second checkbox active if the disable condition is set in the first Jquery?

<input type="radio" class="radio1" name="shipping_method" value="<?php echo $quote['code']; ?>"
                                       />
                            <?php } else { ?>
                                <input type="radio" class="radio2" name="shipping_method" value="<?php echo $quote['code']; ?>"
                                />
                            <?php } ?>
                            <?php echo $quote['title']; ?> - <?php echo $quote['text']; ?>
                            <?php if (isset($quote['description'])) { ?>
                                <br/><small><?php echo $quote['description']; ?></small>
                            <?php } ?>
                        </label>
                    </div>
                <?php endif; ?>
            <?php } ?>

        <?php } else { ?>
            <div class="alert alert-danger"><?php echo $shipping_method['error']; ?></div>
        <?php } ?>

    <?php } ?>
<?php } ?>

<div class="save_shipping_method active">Далее</div>

<p style="display: none">
    <textarea name="comment" rows="8" class="form-control"><?php echo $comment; ?></textarea>
</p>
<div class="buttons" style="display: none">
    <div class="pull-right" style="display: none">
        <input type="button" value="<?php echo $button_continue; ?>" id="button-shipping-method"
               data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary"/>
    </div>
</div>

<script>
    $(document).ready(()=> {


        $('#shipping_method input').change((e) => {
            if (e.target.value === 'pickup.pickup' && e.target.checked) {
                $('.save_shipping_method').addClass('active')
            }
            if(e.target.value === 'cdek.tariff_10_MRG' && e.target.checked) {
                $('#selectCdekPvz').removeClass('disabled')
                
                if(!$('.cdek_selectedPvzInfo').text().length) {
                    $('.save_shipping_method').addClass('disabled') // disabled
                }else {
                    $('.save_shipping_method').addClass('active')
                }

            }else {
                $('#selectCdekPvz').addClass('disabled')
            }
        })

        const onClickCdek = $('#selectCdekPvz.disabled').attr('onclick');
        $('#selectCdekPvz.disabled').removeAttr('onclick')
        $('#selectCdekPvz').click((e) => {
            if(!document.getElementById('selectCdekPvz').classList.contains('disabled')){
                eval(onClickCdek);
            }
        });


    })
</script>


On the site https://posezony.ru/ in the basket, the problem is that the Next button should light up when choosing the second method (pickup, aka pickup.pickup). And with the first method (CDEK), it should light up only after he selects the issue point (#selectCdekPvz).
How can I do it right? The code is not mine and I'm trying to figure it out

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question