Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
238 views
in Technique[技术] by (71.8m points)

html - flask link with checkbox option choice

I have here 3 choices, we can select just one choice. Among this choice there are still other data to enter. My problem: I'm trying to find out which choice I pressed, When I press a checkbox in a list, it is not taken into account. If possible I'd like the checkboxes to be hidden, to be just a link.

<form action="#" method="post" class="formDropDown">
    <ul class="list-unstyled components">
        <span></span>
        <li class="active">
            <a href="#">Home</a>
        </li>
        <li>
            {{ form.hidden_tag() }}
            <a href="#homeSubmenu" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle"><input type="checkbox" name="mycheckbox"/>Par période</a>
            <ul class="collapse list-unstyled" id="homeSubmenu">
                <li><a href="#" class="linkDropDown">
                    {{ form.StartDate.label(class="form-label-input")}}
                    {{ form.StartDate(class='datepicker') }}
                  </li>
                  <li>
                    {{ form.EndDate.label(class="form-label-input")}}
                    {{ form.EndDate(class='datepicker') }}

                    </a>
                </li>
            </ul>
        </li>

        <li>
            <a href="#annee" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle"><form method="POST" action="/"><input type="checkbox" name="mycheckbox"/><span>Par année</span></a>
            <ul class="collapse list-unstyled" id="annee">
                <li><a href="#" class="linkDropDown">
                    {{ form.AllYear.label(class="form-label-input")}}
                    {{ form.AllYear(class='datepicker') }}
                    
                    </a>
                </li>
            </ul>
        </li>
        <li>
            <a href="#"><input type="checkbox" name="mycheckbox" hidden/><span>Tout</span></a>
        </li>
        <li>
            <input type="submit">
        </li>
    </ul>
</form>



class ExampleForm(Form):
    StartDate = DateField('Debut', format='%Y-%m-%d')
    EndDate = DateField('Fin', format='%Y-%m-%d')
    AllYear = DateField('Année', format='%d')

@app.route('/', methods=['GET', 'POST'])
def hello_world():
    if(request.method =='POST'):
        print("hey")
        print(request.form.getlist('mycheckbox'))
    form = ExampleForm()
    return render_template('otherTry.html', form=form)
question from:https://stackoverflow.com/questions/66062359/flask-link-with-checkbox-option-choice

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...