is not checking whether a button is checked or not

Asked

Viewed 42 times

0

if (document.getElementById("circular_select").checked === true) {
  piechart();
}
if (document.getElementById("barras_select").checked === true) {
  alert("You have selected Option 1");
}
<div class="btn-group custom-btn-group  " data-toggle="buttons" >
  <label class="btn btn-default active">
    <img src="img/3d-pie-chart-icon.png" alt=""/>
    <input type="radio" class="form-control" name="feature" value="opt0"  id="circular_select" checked="checked"    />

  </label>
  <label class="btn btn-default ">
    <img src="img/SEO-icon.png" alt=""/>
    <input type="radio" class="form-control"  name="feature" value="opt1" id="barras_select"  />
  </label>
</div> 

1 answer

0

If you put a alert() in the first if it will be fired, there must be something wrong with its piechart function();

Example:

if (document.getElementById("circular_select").checked === true) {
  alert('check 1');
}
if (document.getElementById("barras_select").checked === true) {
  alert('check 2');
}
<div class="btn-group custom-btn-group  " data-toggle="buttons">
  <label class="btn btn-default active">
    <img src="img/3d-pie-chart-icon.png" alt="" />
    <input type="radio" class="form-control" name="feature" value="opt0" id="circular_select" checked="checked" />
  </label>
  <label class="btn btn-default ">
    <img src="img/SEO-icon.png" alt="" />
    <input type="radio" class="form-control" name="feature" value="opt1" id="barras_select" />
  </label>
</div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.