Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8167475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:12:08+00:00 2026-06-06T20:12:08+00:00

I have a text submission box, a category dropdown and then three sport dropdowns

  • 0

I have a text submission box, a “category” dropdown and then three “sport” dropdowns (each sport dropdown containing a list of categorized sports. I want to submit all three forms with one input button (only submit the one sport drop down that has been selected). With this code the text and content forms submit fine as does the category but the sport selector doesn’t work it always has the postelement of “sea” which is the first group. What is wrong with my if elif statements??

<form method="post">
        <div class="row">
        <div class="span6"> 
            <h4>post something!</h4>
              <label>
                <input type="text" placeholder="Subject" name="subject" value="{{subject}}">
              </label>

              <label>
                <textarea style="height: 100px; width: 540px;" name="content">{{content}}</textarea>
              </label>
            {% if error %}
              <div class="alert alert-error">Error: {{error}}</div>
            {% endif %}

           </div>

        <div class="span2"> 
                <h4>categories</h4>
                <select name="postcategory">
                    <option>choose a category</option>
                    <option>general</option>
                    <option>discussion</option>
                    <option>adventures</option>
                    <option>review</option>
                    <option>badge applications</option>
                </select>
        </div>

        <div class="span2 offset1">
                <h4>choose element and/or sport</h4>
                <select name="postsport">
                    <option value="general sea">--general sea--</option>
                    <option value="sailing">sailing</option>
                    <option value="diving">diving</option>
                    <option value="sailing">surfing</option>
                    <option value="kite boarding">kite boarding</option>
                    <option value="kayaking">kayaking</option>
                    <option value="general air">--general air--</option>
                    <option value="skydiving">skydiving</option>
                    <option value="paragliding">paragliding</option>
                    <option value="hang gliding">hang gliding</option>
                    <option value="base jumping">base jumping</option>
                    <option value="balloons">balloons</option>
                    <option value="general land">--general land--</option>
                    <option value="rock climbing">rock climbing</option>
                    <option value="hiking">hiking</option>
                    <option value="biking">biking</option>
                    <option value="skiing">skiing</option>
                    <option value="snowboarding">snowboarding</option>
                </select>
            </div>

           </div>
           <input class="btn" type="submit">
            </form>

Here is my python to handle this information
postcategory = self.request.get(‘postcategory’)
postsport = self.request.get(‘postsport’)
postelement = “general”

        if postcategory == "choose a category":
            postcategory = "general"

        if postsport == "sailing" or "diving" or "surfing" or "kite boarding" or "kayaking" or "general sea":
            postelement ="sea"

        elif postsport == "skydiving" or "paragliding" or "hang gliding" or "base jumping" or "balloons" or "general air":
            postelement ="air"

        elif postsport == "rock climbing" or "hiking" or "biking" or "skiing" or "snowboarding" or "general land":
            postelement ="land"

        else:
            postelement="general"
            postsport = "general"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:12:10+00:00Added an answer on June 6, 2026 at 8:12 pm

    This :

    if postsport == "sailing" or "diving" or "surfing" or "kite boarding" or "kayaking" or "general sea":
            postelement ="sea"
    

    reads as :

    test = ("sailing" or "diving" or "surfing" or "kite boarding" or "kayaking" or "general sea")
    if postport == test:
        postelement ="sea"
    

    In this case, since a non-empty string has a true value in a boolean context, and since the “or” operator returns the first operand having a true value, test will be bound to “sailing”. cf the following interactive session for an illustration:

    Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) 
    [GCC 4.4.5] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> "a" or "b" or "c"
    'a'
    >>> "" or "b" or ""
    'b'
    >>> 
    

    The test you want is:

    if postsport in ("sailing", "diving", "surfing", "kite boarding", "kayaking", "general sea"):
        postelement ="sea"
    

    An even better solution would be to use a dict:

    sportelements = {
        "sailing" : "sea",
        "diving" : "sea",
        # etc
        }
    postelement = sportelements.get(postport, "general")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have text input boxes. There is validation for each of the boxes using
I have text file with something like first line line nr 2 line three
I have a simple ASP.Net MVC View which contains an FCKeditor text box (created
I have a form. And an text box inside it. I wrote validation for
I have a form on a View with a dropdown list, implemented with DropDownListFor().
I have text next to a image (red square for now). When i make
I have text like this format term: 156^^^:^^59 datainput Or term: 156^^^:59 datainput or
I have text within a paragraph tag that that fits snug on the bottom
I have text I am displaying in SIlverlight that is coming from a CMS
I have text file with some stuff that i would like to put into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.