Hi!
I'm new to Mochikit but from what I've done with it so far it is really
much better than raw JavaScript.
I am trying to change a set of <option>s inside a <select> using the
following code:
========================================================
var gotMetadata = function (oData) {
var payload = evalJSONRequest(oData);
for (indice in payload.analises) {
analise = payload.analises[indice];
alert(analise[0]);
alert(analise[1]);
// So far, so good. Everything is shown.
replaceChildNodes("analises_ref", OPTION({"value":analise[0]},
analise[1]));
// Nothing happens here...
alert(analise[0]);
alert(analise[1]);
// ... nor here.
}
};
var metadataFetchFailed = function (err) {
alert("Unable to fetch data from database.");
};
function getAnalisesToxicologia() {
var xmlHttpReq = getXMLHttpRequest()
xmlHttpReq.open("POST", "/toxicologia/obterAnalises", true);
xmlHttpReq.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
var d = sendXMLHttpRequest( xmlHttpReq, "tipo_id=" +
escape(getElement("tipo").value));
d.addCallbacks(gotMetadata, metadataFetchFailed);
};
========================================================
It is a bunch of "cut & paste" code that a beginner has found :-)
My HTML template -- I'm using Kid, this is all within TurboGears (i.e.
a Python template) -- has the following relevant part:
========================================================
<SELECT id="analises_ref" name="analisesDisponiveis" multiple="True"
ondblclick="moveSelectedOptions(this.form['analisesDisponiveis'],this.form['analisesAFazer'],true)"
size="10">
<option py:for="analise_id, analise in analises"
py:attrs="value=analise_id" py:content="analise">anĂ¡lise</option>
</SELECT>
========================================================
And the resulting HTML looks like this:
========================================================
<SELECT
ONDBLCLICK="moveSelectedOptions(this.form['analisesDisponiveis'],this.form['analisesAFazer'],true)"
MULTIPLE ID="analises_ref" NAME="analisesDisponiveis" SIZE="10">
<OPTION VALUE="5">Chumbo</OPTION>
</SELECT>
========================================================
I'd like to have several <option> entries, with the values that I'm
getting from the Database, but as I've written on the code, after the
"replaceChildNodes()" call -- including it --, nothing more happens. I
suspect I have some syntax error or conceptual error that is preventing
it from working, but I couldn't find where.
Anyone can give me a hand with this? Any hints?
TIA,
Jorge Godoy.