Home > OS >  how do you change color of disable radio button
how do you change color of disable radio button

Time:03-11

I want to know how can I change the color of disabled the radio button in my case I have used if case to disable a full day when a shared radio button is selected. how can the full-day radio button change to grey like shown in disable radio button once the shared radio box is selected? need help pls

function check() {
  if (document.getElementById('shared').checked) {
    document.getElementById('full-day').disabled =true
    document.getElementById('full-day').checked =false
    document.getElementById('half-day').checked =true
  }
  else document.getElementById('full-day').disabled =false
}
label[for=full-day] {
    position: relative;
    color: orangered;
    font-size: 24px;
    border: 2px solid orangered;
    border-radius: 5px;
    align-items: center;
    display: flex;
    cursor: pointer;
    height: 36px;
    width: 116px;
    margin: 20px 20px 0px 0px;
    justify-content: center;
    
}
input[type="radio"] {
    display: none;
}

label[for=private] {
    position: relative;
    color: orangered;
    font-size: 24px;
    border: 2px solid orangered;
    border-radius: 5px;
    align-items: center;
    display: flex;
    cursor: pointer;
    height: 36px;
    width: 80px;
    margin: 20px 20px 0px 0px;
    justify-content: center;
}

label[for=shared] {
    position: relative;
    color: orangered;
    font-size: 24px;
    border: 2px solid orangered;
    border-radius: 5px;
    align-items: center;
    display: flex;
    cursor: pointer;
    height: 36px;
    width: 80px;
    margin: 20px 20px 0px 35px;
    justify-content: center;
}
label[for=half-day] {
    position: relative;
    color: orangered;
    font-size: 24px;
    border: 2px solid orangered;
    border-radius: 5px;
    align-items: center;
    display: flex;
    cursor: pointer;
    height: 36px;
    width: 150px;
    margin: 20px 20px 0px 0px;
    justify-content: center;
}

input[type="radio"]:checked label {
    background-color: orangered;
    color: white;
}

input[type="radio"]:checked label:before {
    height: 16px;
    width: 16px;
    border: 10px solid white;
    background-color: orangered;
}

label[for=full-day-disabled]{
    color: #666666;
    border: 2px solid  #666666;
    position: relative;
    font-size: 24px;
    border-radius: 5px;
    align-items: center;
    display: flex;
    cursor: not-allowed;
    height: 36px;
    width: 80px;
    margin: 20px 20px 0px 35px;
    justify-content: center;
}
<div style="display: flex; width: 100%">
  <input type="radio" name="occupancy" id="private" onchange="check()" value="private" checked="checked">
  <label for="private">Private</label>
  <input type="radio" name="occupancy" id="shared" onchange="check()" value="shared">
  <label for="shared">Shared</label>
</div>
<div style="display: flex; width:100%">
  <input type="radio" name="package" id="full-day" checked="checked">
  <label for="full-day">Full Day</label>
  <input type="radio" name="package" id="half-day">
  <label for="half-day">Half Day</label>
</div>

<div style="display: flex; width:100%">
  <input type="radio" name="package" id="full-day">
  <label for="full-day-disabled">disabled</label>
</div>

hi, I want to know how can I change the color of disabled the radio button in my case I have used if case to disable a full day when a shared radio button is selected. how can the full-day radio button change to grey like shown in disable radio button once the shared radio box is selected? need help pls

CodePudding user response:

I use some form of this:

input[type="radio"]:disabled   label {
    filter: grayscale(100%);
    opacity: .5;
    pointer-events: none;
}
  • Related