Hi Brad, Have a look at http://code.djangoproject.com/wiki/AJAXWidgetComboBox it seems to do most of what you are after.
On 02/10/06, brad <[EMAIL PROTECTED]> wrote: > > Hello. I am trying to build a view to lookup a model field and return > an array based on the data sent to the view. The goal is to send the > contents of the "value" tag in an html select statement( i.e. in > <option value=SOME_VALUE>OPTION</option> to send the SOME_VALUE part) > to a Django view with a Dojo request call, have the Django view build > an array based on SOME_VALUE, and ultimately send the array back > through "return HttpResponse(array). So far I understand how to send > the contents of the "value" tag and how to send the array back through > the "return" statement. However, I do not know how to build the array. > Belowe I posted a segment of my "models.py", and in it you can see that > I will want to populate the array with valus from the model field > "name" in the class Game. I want to use SOME_VALUE to filter out the > rows in the field "name" that have name.id == SOME_VALUE. Any thoughts > on how I may accomplish this? Thank you in advanced for any help that I > may receive. Here's what I have so far: > > ######### > select.html > ######### > <html> > <head> > <title> title </title> > <script type="text/javascript" > src="/site_media/js/dojo/dojo.js"></script> > > <script type="text/javascript"> > dojo.require("dojo.event.*"); > dojo.require("dojo.widget.*"); > dojo.require("dojo.widget.Button"); > dojo.require("dojo.json"); > > function helloPressed(x) > { > dojo.io.bind({ > url: '1/', > handler: helloCallback, > method: 'post', > content: x > }); > } > > function helloCallback(type, data, evt) > { > if (type == 'error') > alert('Error when retrieving data from the server!'); > else > alert(data); > } > </script> > > </head> > <body> > <form id="myForm" method="POST"> > <select name="staticSELECT" id="satic" > onchange="helloPressed(this.value);"> > <option value="0"> Pick One</option> > {% for game in games %} > <option value="{{ game.id }}">{{ game.name }}</option> > {% endfor %} > </select> > </form> > </body> > </html> > > > ######### > models.py > ######### > class Game(models.Model): > name = models.CharField(maxlength=200) > > class Admin: > pass > > def __str__(self): > return self.name > > ####### > views.py > ####### > def select(request): > data = "If statement not evaluated" > > if request.POST: > data = "POST request received" > > data = unicode( data, "utf-8") > json = simplejson.dumps(data) > return HttpResponse(json) > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---