title: Flask receiving null from html template
body: <p>I am creating a site which takes surveys.I am taking the questions and their associated options and displaying them. They successfully display but I am not able to access their id to update their values.</p>
  
  <p>I have previously tried using flask's way of requesting selection from multiple radio buttons but it gives me a  bad request error.</p>
  
  <p>This is my html page:</p>
  
  <pre><code>{% extends "layout.html" %}
  
  {% block title %}
      Take Survey
  {% endblock %}
  
  {% block main %}
  
  
    {% for survey in surveys %}
    &lt;h2 &gt;{{survey.topic}}&lt;/h2&gt; &lt;br&gt;
  
    &lt;form action="/take" method="post" &gt;
  
      &lt;script&gt;
          function change( val1,val2) {
                          document.getElementById(val1).value = val2
                      }
      &lt;/script&gt;
    {% for question in questions %}
          &lt;input type="hidden" name="{{question.id}}" id="{{question.id}}"&gt;
        &lt;h3&gt;Q. {{question.question}}&lt;/h3&gt; &lt;br&gt;&lt;br&gt;
  
              {% for option in options[question.id] %}
  
                  &lt;input type="radio" onselect="change({{question.id}},{{option.id}})" &gt; {{option.option}}&lt;br&gt;
  
              {% endfor %}
  
  
  
      {% endfor %}
      &lt;br&gt;
          &lt;input type="hidden" name="survId" value="{{survey.id}}"&gt;
          &lt;input type="hidden" name="button" id="bqp"&gt;
          &lt;button class="btn btn-primary"  id="continue" type="submit"&gt;Continue&lt;/button&gt;
          &lt;button class="btn btn-primary"  id ="cancel" type="submit"&gt;Cancel&lt;/button&gt;
           &lt;script&gt;
          document.getElementById("continue").addEventListener("click", buttonFind);
          document.getElementById("cancel").addEventListener("click", buttonFind);
  
          function buttonFind() {
              document.getElementById("bqp").value = this.id
          }
      &lt;/script&gt;
          &lt;br&gt;
      &lt;/form&gt;
  
  
      {% endfor %}
  
  {% endblock %}
  </code></pre>
  
  <p>And this is my take route:</p>
  
  <pre><code>@app.route("/take", methods= ["GET","POST"])
  @login_required
  def take():
  
  if request.method =="POST":
      survey = request.form.get("survId")
      button = request.form.get("button")
  
      if button == "cancel" :
          searches=db.execute("SELECT * FROM surveys ORDER BY views DESC")
          return render_template("homepage.html",searches=searches)
  
      db.execute("UPDATE surveys SET views = views + 1 WHERE id=:surveyid",surveyid=survey)
      questions = db.execute("SELECT id FROM questions WHERE surveyid=:surveyid", surveyid=survey)
  
      for question in questions:
          choice  = request.form.get(str(question))
          db.execute("UPDATE options SET choicevalue = choicevalue + 1 WHERE option=:option", option=choice)
  
      searches=db.execute("SELECT * FROM surveys ORDER BY views DESC")
      return render_template("homepage.html",searches=searches)
  
  else:
      return render_template("take.html")
  </code></pre>
  
  <p>In my opinion I should be receiving the optionid from the flask but the following SQL queries end up running indicating that i receive null:</p>
  
  <pre><code>UPDATE surveys SET views = views + 1 WHERE id='41'
  DEBUG:cs50:SELECT id FROM questions WHERE surveyid='41'
  DEBUG:cs50:UPDATE options SET choicevalue = choicevalue + 1 WHERE option=NULL
  DEBUG:cs50:UPDATE options SET choicevalue = choicevalue + 1 WHERE option=NULL
  </code></pre>