0
{% for movie in movies%}

   <div class="card">
      <form action="moviedetail.html" method="post">
         <input type="image" class="card-img-top" name = "posterurl" value="{{movie}}" alt="poster" src="{{movie}}">
      </form>
   </div>

{% endfor %}

Here is the code on the html, I just created a bunch of input forms with a for loop. I want to post the data {{movie}} to the next page on click.

@data.route("/moviedetail.html", methods=['POST'])
def getMovieDetail():
    poster = request.form['posterurl']
    return render_template("moviedetail.html", poster = poster)

Here is the receiving end on the mainroutes.py. I keep getting a 400 error, bad key request on ['posterurl']. Im guessing the error is because I created multiple forms with a for loop using the same name, but I can't think of any other way to post the data.

Ian Lee
  • 91
  • 2
  • 8
  • Use a ` – Rahul Bharadwaj Oct 26 '20 at 04:47
  • ohh, sorry! i wasn't clear in my original post. i edited my post. so the situation is that I can't use select and options, because each element has to be styled like a bootstrap card. the website looks like [this](https://i.imgur.com/fWe5CTN.png). each image is clickable and posts information to the detail page of each individual movie. – Ian Lee Oct 26 '20 at 08:36

0 Answers0