locked
bootstrap 3 radio button group not holding the clicked button RRS feed

  • Question

  • User379720387 posted

    I am setting checked with one of these (doOne, doTwo, doFive, or doAll) set to true on page load.

    <div class="btn-group daysSelector" data-toggle="buttons">                                          
                                                <label class="btn btn-warning">
                                                    <input type="radio" name"daysToLoad" checked="@doOne" value="1">1 day
                                                </label>
                                                <label class="btn btn-warning">
                                                    <input type="radio" name"daysToLoad" checked="@doTwo" value="2">2 days
                                                </label>
                                                <label class="btn btn-warning">
                                                    <input type="radio" name"daysToLoad" checked="@doFive" value="5">5 days
                                                </label>
                                                <label class="btn btn-warning">
                                                    <input type="radio" name"daysToLoad" checked="@doAll" value="99">all
                                                </label>
                                                <input type="hidden" id="daysToLoad" name="daysToLoad" value="@daysToLoad" />
                                            </div>

    In the browser tools I can see checked="checked" for the radio button that has doXXX = true

    <div class="btn-group daysSelector" data-toggle="buttons">
                                                
                                                <label class="btn btn-warning">
                                                    <input type="radio" name"daystoload"="" value="1">1 day
                                                </label>
                                                <label class="btn btn-warning">
                                                    <input type="radio" name"daystoload"="" value="2">2 days
                                                </label>
                                                <label class="btn btn-warning">
                                                    <input type="radio" name"daystoload"="" checked="checked" value="5">5 days
                                                </label>
                                                <label class="btn btn-warning">
                                                    <input type="radio" name"daystoload"="" value="99">all
                                                </label>
                                                <input type="hidden" id="daysToLoad" name="daysToLoad" value="5">
                                            </div>

    Yet, the radio button is not actually pressed.

    Wednesday, June 24, 2020 8:28 PM

Answers

  • User303363814 posted

    Your html is not valid

    name"daystoload"="" 

    is not a valid attribute

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 24, 2020 11:07 PM