[Twisted-web] LivePage client.set()

Donovan Preston dp at ulaluma.com
Tue Mar 22 09:55:27 MST 2005

On Mar 20, 2005, at 8:24 PM, Dave Cook wrote:

> I'd like to set the <option>s in on <select> based on user input from
> another (using Nevow 0.3).  I tried something like
> client.set("mySelect", [tags.option[optionText] for optionText  in
> myListOfStrings])
> in my handler.  This works great for Safari, but Firefox seems to
> ignore the <option> tags and just inserts text into the DOM at that
> point.  *Should* the above work generally, or was I just lucky with
> Safari?

Doing things like this is highly dependent on how well a browser lets 
you arbitrarily swap out dom elements after the page is already 
rendered. As you observed, this works on Safari but not IE or Firefox. 
I don't think there is really any technique besides experimentation to 
determine what does and does not work.

.innerHTML is not standard, but it was invented by IE and is very 
widely supported by all other major browsers now. It works the most 
reliably of any techniques I have found short of using the actual w3c 
DOM createElement/appendChild APIs to programatically construct nodes 
in the client, which would be a real pain in the ass to render.

I suggest trying something like this instead to see if browsers can 
cope with it a little better:


client.set("mySelect", tags.select[[tags.option[optionText] for 
optionText in myListOfStrings]])


More information about the Twisted-web mailing list