Hi Richie,
> Now,
> <select id="box2" onchange="ajaxUpdater('ajax_day', '/ajax/
> populate.php?show=day&month=' + getsel('box2')">
> <div id='ajax_regions'></div>
> </select>
>
> , doesn't work...
That's because it's invalid HTML. You can't put divs inside select
elements. I'm pretty sure only option and optgroup are allowed, but
in any case I'm certain div isn't. You can use the W3C Markup
Validator[1] to keep your HTML valid.
[1]
http://validator.w3.org
With your updated example of the select box within the div and
replaced via an Ajax.Updater: Using innerHTML to create form elements
doesn't work reliably, and under the covers Ajax.Updater uses
Element#update, which uses innerHTML. Separate from your specific
problem of the event handler not being called (that could be easily
solved using Event#observe), you'll run into issues with some browsers
not recognizing the replaced select box at all. You pretty much have
to add form elements using DOM methods (appendChild and the like).
I take it the goal is to change the options available within the
select box when the value changes? (OT: Doesn't that make for a
jittery user experience?) Rather than using HTML, I think you're
better off manipulating the options array of the select box directly.
It's been years since I did that, so I'm sure what I used to do is old-
fashioned -- I'll leave it to you to Google changing the options, or
for someone who's done it more recently to chime in.
So, not a complete answer, but hopefully it's useful to know what's
going wrong...
HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available