• This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #2189

    Week 9 Froshims: Why failure despite name and sports chosen
    byu/DigitalSplendid incs50

    byu/DigitalSplendid from discussion



    The suggestion from Reddit is correct. When submitting a form, the <option> tags within a <select> element need a value attribute to pass data when the form is submitted. Currently, your <option> tags only contain the display text ({{ sport }}), but they need a corresponding value that will be submitted with the form. Here’s how you can modify your code to include the value attribute:

    {% extends "layout.html" %}
    {% block body %}
        <form action="/register" method="post">
            <input autocomplete="off" autofocus name="name" placeholder="Name" type="text">
            <select name="Sport">
                <option disabled selected value="">Sport</option>
                {% for sport in sports %}
                    <option value="{{ sport }}">{{ sport }}</option>
                {% endfor %}
            <button type="submit">Register</button>
    {% endblock %}

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Scroll to Top