Re: populating choice in newForm instance

2007-03-28 Thread tyman26

How would you go about reloading the page?  Would you submit the form
and post the information back again?   I guess I'm having trouble
figuring out how to reload the page and keep the same information that
was previously there, plus load the states in the select box.

On Mar 28, 12:48 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> On Mar 27, 5:10 pm, "tyman26" <[EMAIL PROTECTED]> wrote:
>
> > I guess a simpler quesiton would be:  How can I populate a text box
> > dynamically withinformationfrom thepostfrom the same form?  Or is
> > there maybe another way to accomplish this possibly with a custom
> > inclusion tag?  Any help would be much appreciated.  There must be
> > some easier way to do this.
>
> Once your web page has loaded and your user selected an option (the
> mailing country choice), the only ways I can think of modifying the
> contents of a second control on the same webpage is either modifying
> the data of the control dynamically using Javascript or reloading the
> page.
> Roberto Zoia


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: populating choice in newForm instance

2007-03-28 Thread [EMAIL PROTECTED]

On Mar 27, 5:10 pm, "tyman26" <[EMAIL PROTECTED]> wrote:
> I guess a simpler quesiton would be:  How can I populate a text box
> dynamically with information from the post from the same form?  Or is
> there maybe another way to accomplish this possibly with a custom
> inclusion tag?  Any help would be much appreciated.  There must be
> some easier way to do this.

Once your web page has loaded and your user selected an option (the
mailing country choice), the only ways I can think of modifying the
contents of a second control on the same webpage is either modifying
the data of the control dynamically using Javascript or reloading the
page.
Roberto Zoia


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: populating choice in newForm instance

2007-03-27 Thread tyman26

I guess a simpler quesiton would be:  How can I populate a text box
dynamically with information from the post from the same form?  Or is
there maybe another way to accomplish this possibly with a custom
inclusion tag?  Any help would be much appreciated.  There must be
some easier way to do this.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



populating choice in newForm instance

2007-03-27 Thread tyman26

I have a form with 2 select boxes that I load into a template.
Initially the "mailing country" choice is loaded with all available
countries and the "mailing states" is empty because a country hasn't
been selected yet.  When a user selects a "mailing country" choice, I
want all the states from that country to populate in the "mailing
state" choice box.  I know this is all possible with javascript on the
fly, but I would rather not code it that way.  I have tried posting
the information back to the same page once the user changes the select
box, but if the user has any errors those are displayed too.  Can I
somehow reload the page and keep the information that was previously
there, and then restrict the errors from being shown.

Here is my code:
-
--FORMS.PY--
-
class CustomerAdd(forms.Form):

mailing_country =
forms.ChoiceField(widget=forms.Select(attrs={'onChange':'country_change()'}),
choices=StaticCountries().GetListForSelect(), label=u'Mailing
Country', required=False)

mailing_state =
forms.ChoiceField(choices=StaticRegions().GetListForSelect(None),
label=u'Mailing State', required=False)


--VIEWS.py---
-
def customer_add_view(request):
if request.method == 'POST':
form = CustomerAdd(request.POST)
"""
if form.is_valid():
entry = form.save(commit=False)
entry.save()
return HttpResponseRedirect("/")
"""
else:
form = CustomerAdd()
t = loader.get_template('customer/new_customer.html')
c = Context({
'form': form,
'is_valid':form.is_valid()
})
return HttpResponse(t.render(c))
--
TEMPLATE.PY---
--

function country_change(){
  document.forms[0].method = "get";
  document.forms[0].submit();
}


{{test}}


{{form.mailing_country.label}}{{form.mailing_country}}{{form.mailing_country.errors}}


{{form.mailing_state.label}}{{form.mailing_state}}{{form.mailing_state.errors}}






--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---