Howdy Matt!
Here is a small, complete working sample.  When you initially load the
page it just displays the choices and prompts you to select a value and
click submit.  When you submit it, it redisplays the form and then
displays what choice you selected.

urls.py:

from django.conf.urls.defaults import *

urlpatterns = patterns('test.views',
    (r'^get_select_value/$','get_select_value'),
)

views.py:

from django.shortcuts import render_to_response

def get_select_value(request):
    if "sample" in request.POST:
        selected_value = request.POST["sample"]
    else:
        selected_value = None
    return render_to_response("get_select_value.html",
{'selected_value' : selected_value})

get_select_value.html (the template):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>get_select_value</title>
</head>
<body>

<form action="." method="post">
<p>
<select name="sample">
        <option value="A">A</option>
        <option value="B">B</option>
        <option value="C">C</option>
        <option value="D">D</option>
        <option value="E">E</option>
</select>
<input type="submit" value="Submit" />
</p>
</form>
{% if selected_value %}
<p>You picked {{selected_value}}.</p>
{% else %}
<p>Choose the value you want and click <em>Submit</em>.</p>
{% endif %}
</body>
</html>


--gordy


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to