Results 1 to 2 of 2

Thread: how to display the 'Status' side by side with the Switch?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    782

    how to display the 'Status' side by side with the Switch?

    Hi All,

    I'm learning HTML, I have HTML code below, how to display the 'Status' side by side with the Switch?
    Code:
    <div>
           <label>Status</label>
                  <label class="c-switch c-switch-pill c-switch-label c-switch-primary mb-1">
                       <input type="checkbox" class="c-switch-input" id="input-active" name="active" value="true" @(Model.active ? "checked" : "")>
                       <span class="c-switch-slider" data-checked="&#x2713;" data-unchecked="&#x2715;"></span>
                  </label>
           </div>

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: how to display the 'Status' side by side with the Switch?

    You can use JavaScript to:
    1. Get the input by its id
    2. Get the input's checked value

    Code:
    var checkbox = document.getElementById('input-active');
    var checkboxChecked = checkbox.checked;
    
    console.log(checkboxChecked);
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width