Re: Refer to dynamically generated objects during page load



Thomas 'PointedEars' Lahn wrote:
Sisilla wrote:
On Sep 8, 11:52 am, Thomas 'PointedEars' Lahn <PointedE...@xxxxxx>
wrote:
Sisilla wrote:
I am using
[element].innerHTML=xmlHttp.responseText
to generate some multiple selection dropdowns. Before the page is
finished loading, I would like to manipulate the dropdowns by calling
some javascript functions. The trouble is that I cannot refer to the
dropdownobjects until after the page has loaded.
Is there any way to accomplish what I'm trying to do without
constructing the dropdowns with DOM document methods?
xmlHttp.responseXML yields an (I)XML(DOM)Document object reference, given a
response served with an XML media type. You can manipulate that document
with DOM methods (you have to, or it would have to be PITA-string-parsing),
and assign the serialization of the document tree to `innerHTML'. That
said, I don't think you need `innerHTML' anymore then.

And if you think about it, if the responseText value is the result of a
database query as you state in [1], the server should generate the
appropriate response in the first place, without you having to script
anything client-side.
[...]

Please trim your quotes, and don't quote signatures unless you are referring
to them. TIA.

FYI: Some multiple option select elements are getting their options
from the database, and based on another query, certain options will be
pre-selected. Is this scenario really that impossible to imagine?

No, it is conceivable. I am doing that myself.

Your reply has left me with an idea, however. I will try to execute
both queries before updating innerHTML, and try to assign "selected"
attributes to the appropriate options based on the second query. I'll
let you know how it turns out. Thanks.

Good luck.

However, I am still not convinced that using `innerHTML' (which is a
proprietary property, BTW) is even necessary here. If you change the
content of the document when it is just loaded anyway, why could the
server not generate the proper markup (with all options properly
selected) in the first place?


PointedEars
All very interesting responses. What sizilla may wish is along the lines
1. listbox A, dynamically generated
2. listbox B where the contents of this listbox is chosen according to a selection in listbox A.
So theoretically if listbox A has 4 selections, you may have four different lists in lisbox B.
This is a common occurrence in RIA applications. It is perhaps possible to do this via innerHTML replacement, however, the way I have done it is via direct manipulation of the option arrays in the listboxes.
As PointedEars suggests you may no need innerHTML replacement
.



Relevant Pages

  • Re: Refer to dynamically generated objects during page load
    ... to generate some multiple selection dropdowns. ... You can manipulate that document ... and assign the serialization of the document tree to `innerHTML'. ...
    (comp.lang.javascript)
  • Re: Last Selection from MultiSelect Listbox
    ... What you can do is track the listbox selection in an array by modifying an array every time the listbox is changed. ... Dim idx As Integer, i As Integer ...
    (microsoft.public.excel.programming)
  • Re: Select range & copy
    ... I changed the range name of the ListBox stuff to mRefList ... "tvac" wrote: ... > Private Sub ListBox1_Click ... >> The first 2 columns have common data regardless of the selection. ...
    (microsoft.public.excel.programming)
  • Re: List of values
    ... I have to assume that the listbox is set to ... single-selection listbox. ... Private Sub ButtonOK_Click ... have shown is only the code to load the data into the listbox and display ...
    (microsoft.public.word.vba.general)
  • Re: Creating a Drop down list where can pick more than one choice
    ... do both tasks (make the listbox visible, and write the selected items into ... <MS ACCESS MVP> ... "Ken Snell MVP" wrote: ... Or do you want each selection to appear in the ...
    (microsoft.public.access.forms)