Как добавить действия в HTML\CSS Radio-button?

Использование системы в различных ситуациях, вопросы программирования сценариев.

Модератор: immortal

Ответить
FredP
Сообщения: 59
Зарегистрирован: Ср авг 23, 2017 5:35 pm
Благодарил (а): 2 раза
Поблагодарили: 2 раза

Как добавить действия в HTML\CSS Radio-button?

Сообщение FredP » Пн июн 25, 2018 2:11 pm

Знатоки HTML\CSS, нашел вот такие симпатичные radio кнопки:

Код: Выделить всё

<div style="text-align: center;margin-top:10%">
<div class="onoffswitch">
    <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch1">
    <label class="onoffswitch-label" for="myonoffswitch1">
        <div class="onoffswitch-inner">
            <div class="onoffswitch-active">
                <div class="onoffswitch-switch">ON</div>
            </div>
            <div class="onoffswitch-inactive">
                <div class="onoffswitch-switch">OFF</div>
            </div>
        </div>
    </label>
</div>
<br><br>
<div class="onoffswitch">
    <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch2" checked>
    <label class="onoffswitch-label" for="myonoffswitch2">
        <div class="onoffswitch-inner">
            <div class="onoffswitch-active">
                <div class="onoffswitch-switch">ON</div>
            </div>
            <div class="onoffswitch-inactive">
                <div class="onoffswitch-switch">OFF</div>
            </div>
        </div>
    </label>
</div>
</div>

<style>

.onoffswitch {
    position: relative;
    width: 100px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
  display: inline-block;
}

.onoffswitch-checkbox {
    display: none;
}

.onoffswitch-label {
    display: block;
    overflow: hidden;
    cursor: pointer;
    border: 0px solid #999999;
    border-radius: 0px;
}

.onoffswitch-inner {
    width: 200%;
    margin-left: -100%;
    -moz-transition: margin 0.3s ease-in 0s;
    -webkit-transition: margin 0.3s ease-in 0s;
    -o-transition: margin 0.3s ease-in 0s;
    transition: margin 0.3s ease-in 0s;
}

.onoffswitch-inner > div {
    float: left;
    position: relative;
    width: 50%;
    height: 30px;
    padding: 0;
    line-height: 30px;
    font-size: 14px;
    color: white;
    font-family: Trebuchet, Arial, sans-serif;
    font-weight: bold;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

.onoffswitch-inner .onoffswitch-active {
    padding-left: 15px;
    background-color: #C2C2C2;
    color: #FFFFFF;
}

.onoffswitch-inner .onoffswitch-inactive {
    padding-right: 15px;
    background-color: #C2C2C2;
    color: #FFFFFF;
    text-align: right;
}

.onoffswitch-switch {
    width: 40px;
    margin: 0px;
    text-align: center;
    border: 0px solid #999999;
    border-radius: 0px;
    position: absolute;
    top: 0;
    bottom: 0;
}

.onoffswitch-active .onoffswitch-switch {
    background: #27A1CA;
    left: 0;
}

.onoffswitch-inactive .onoffswitch-switch {
    background: #A1A1A1;
    right: 0;
}

.onoffswitch-active .onoffswitch-switch:before {
    content: " ";
    position: absolute;
    top: 0;
    left: 40px;
    border-style: solid;
    border-color: #27A1CA transparent transparent #27A1CA;
    border-width: 15px 10px;
}

.onoffswitch-inactive .onoffswitch-switch:before {
    content: " ";
    position: absolute;
    top: 0;
    right: 40px;
    border-style: solid;
    border-color: transparent #A1A1A1 #A1A1A1 transparent;
    border-width: 15px 10px;
}

.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
    margin-left: 0;
}
</style>
Подскажте, куда в них добавить действия мажордомо? На ON скажем setGlobal('Gift_banks.Return_bank_0',1); на офф setGlobal('Gift_banks.Return_bank_0',0);
Аватара пользователя
tarasfrompir
Сообщения: 3216
Зарегистрирован: Ср мар 02, 2016 8:18 pm
Откуда: Украина Пирятин
Благодарил (а): 223 раза
Поблагодарили: 815 раз

Re: Как добавить действия в HTML\CSS Radio-button?

Сообщение tarasfrompir » Пн июн 25, 2018 3:38 pm

onClick='ajaxSetGlobal("%.object_title%.playUrl", document.getElementById("play_url").value);'
Щото типа такого ?
:oops:
Спасибо нам ПОМОЖЕТ..!
mrdenis
Сообщения: 31
Зарегистрирован: Чт мар 19, 2015 7:55 am
Благодарил (а): 6 раз
Поблагодарили: 1 раз

Re: Как добавить действия в HTML\CSS Radio-button?

Сообщение mrdenis » Вт ноя 20, 2018 2:19 pm

Две проблемы тут у меня...

1. Чекбокс при снятии отметка не отправляет серверу свое отключенное состояние. Но это не совсем беда..
2. Происходит объединение стилей со стандартным чекбоксом МДМ... как заменить стиль полностью ?

Заранее спасибо.
Аватара пользователя
Vovix
Сообщения: 1155
Зарегистрирован: Пн янв 27, 2014 1:43 am
Откуда: г.Ижевск
Благодарил (а): 60 раз
Поблагодарили: 531 раз
Контактная информация:

Re: Как добавить действия в HTML\CSS Radio-button?

Сообщение Vovix » Ср ноя 21, 2018 12:04 pm

Вам сюда: viewtopic.php?f=23&t=3960
Мой -CONNECT-
Windows 7(PHP 7.2) + Raspberry Pi(освещение на 1-Wire) + MP751(управление) + ESP8266(сенсоры) + LAN(сенсоры)
-=: Если вам помогло моё сообщение, нажмите кнопку "Поблагодарить за сообщение автора: Vovix" (кнопка Спасибо) справа! :=-
Ответить