On Tuesday, January 4, 2011 8:55:50 PM UTC, hank23 wrote: > > I'm in the process of coding a new screen which I want to use a form > on. I'm also currently coding the new form to go with it. The screen > will have a dropdown box, a conditional textbox, and a submit button, > as well as some other informational fields and a title on it. Since > this is my first explicit attempt at using a form I have the following > questions: > > 1. How does my form get recognized by or associated with the html > screen file? >
Via the view, just as with any other type of content. See the documentation on Using a form in a view: http://docs.djangoproject.com/en/1.2/topics/forms/#using-a-form-in-a-view > 2. What form field type do I use to pass a list/collection in the form > to the screen (Once I get it there I know I can display its individual > items from within a for loop)? > forms.ChoiceField or forms.ModelChoiceField. And you don't need to use a for loop, just render the field via {{ form.myfield }}. > 3. Then once the user selects a value from the dropdown box, how can I > read the value selected, in my view? > By instantiating the form with the values from request.POST. Again, the forms documentation explains all this in 'using a form in a view'. > 4. Finally how do I conditionally display the textbox only if the user > has selected a value from the dropdown box and not display it if a > value was not selected? > You'll need to do this in Javascript. > I would appreciate any help with any or all of the above questions. > Sorry if they're too simple, but I'm a newbie and almost everything > about django is new and not necessarily intuitive to me just yet. > Thanks. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.