title: dynamic dropdown list in python GAE
body: <p>I am using GAE with Python for building an app. I have 2 dropdowns 'applications' and 'versions' in my firstpage( Index.html). I am able to populate the first dropdown dynamically from the database. Based on the selection of the first dropdown, I need to populate the second. I tried with an onchange event and a javascript to capture the selection id in the first dropdown list. but i am not sure how to pass the captured onchangeid to the backend. request.get doesn't seem to work. Appreciate any help.</p>
  
  <p>my main.py looks like</p>
  
  <pre><code>class MainPage(webapp.RequestHandler):
    def get(self):
        proj = db.GqlQuery("SELECT DISTINCT Applicationname FROM Dashboard")
  
        Appname1 = self.request.get('selvalue.value')
        proj1 = Dashboard.all().filter('Applicationname =',Appname1)
  
        values = {'appnames' : proj, 'vernums' : proj1}
        self.response.out.write(template.render('index.html',values))
  
  class Dashboard(db.Model):
     Applicationname = db.StringProperty(required=True)
     Version=db.StringProperty(required=True)
     Type=db.StringProperty()
     Pagename=db.StringProperty(required=True)
     Responsetime=db.StringProperty(required=True)
  
  
  class DisplayHandler(webapp.RequestHandler):
    def post(self):
        Appname=self.request.get('Applicationname')
        Vernum=self.request.get('Version')
        query = Dashboard.all().filter('Applicationname =',Appname).filter('Version =',Vernum)
        values = {'query' : query}
        self.response.out.write(template.render('response.html',values))
  
  def main():
      application = webapp.WSGIApplication(
                                       [('/', MainPage),
                                        ('/Display', DisplayHandler)
                                       ],
                                       debug=True)
      run_wsgi_app(application)
  
  if __name__ == "__main__":
    main()
  </code></pre>
  
  <p>my index.html looks like this</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt; My First Web Page &lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" href="style.css"&gt; &lt;/link&gt;
  &lt;script type="text/javascript"&gt;
  function myFunction(Applicationname)
  {
  var selvalue = document.getElementById("Applicationname");      
  }
  
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;form action="/Display" method="post"&gt;
  
          &lt;select name="Applicationname" id="Applicationname" onchange="myFunction()"  &gt;
              &lt;option value="Select"&gt;---Select---&lt;/option&gt;
                  {% for q in appnames %}
              &lt;option value="{{q.Applicationname}}"&gt;{{q.Applicationname}}&lt;/option&gt;
                  {% endfor %}
  &lt;/select&gt;
  
   &lt;br&gt;&lt;br&gt;
  
  Select the Version number
          &lt;select name="Version" id="Version"&gt;
              &lt;option value="Select"&gt;---Select---&lt;/option&gt;
              {% for r in vernums %}
              &lt;option value="{{q.Version}}"&gt;{{r.Version}}&lt;/option&gt;
              {% endfor %}
          &lt;/select&gt;
  
      &lt;input type="submit" value="Submit" align="center"/&gt;
      &lt;/form&gt;
  </code></pre>