On Thursday 29 October 2009 22:33:27 Brett wrote:
> Hey all, I'm writing a small internal website for a lab, trying to
> create a system to organize our various genes/proteins etc.  Since we
> only use a small number of bacteria and strains, I wanted to offer the
> user a series of drop boxes - one for the species, another for the
> strain, etc.  But what strains are available a different for each
> species, so the second box would be empty and/or change when the first
> box was selected.  Any idea how I could implement this in Django?
> 
> -Brett
> 

Since Django is server side, once it sends a reply to the client, it's 
finished with the client, till a new request comes in. It can't solve client 
side processing, which is where javascript comes into play and the answer to 
your problem.

I see two ways to solve this problem, the first one is to go the sexy route 
and add ajax to the page.  With django all you need to do is provide a url 
that returns a response to your javascript script can use (ideally a json 
response) and turn that response into your second drop box. 

The second way is to have a javascript script already populated with all 
possible choices and update the box from this script.  You can have help with 
this by using a template tag that fills in this particular part of the script.

In this case, depending on how many choices are available, the second way 
might not be the most efficient. 


Mike
-- 
You have literary talent that you should take pains to develop.

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to