There isn't a form module.  But, what you're looking for can probably
be done using some MochiKit.DOM magic:

var MyDic = [{'value':1, 'text':Text1}, {'value':2, 'text':Text2}];
var sel = SELECT({});
for (var i in MyDic)
{
  sel.appendChild(MochiKit.DOM.OPTION({'value': MyDic[i].value},
MyDic[i].text));
}

Then just append the DOM node sel to wherever you want it in the
document.  Also don't forget to include DOM.js, Iter.js, and Base.js
for this code.

I don't know if there's a better way to do it -- maybe someone else on
the list knows a way to apply an array of OPTION nodes to the end of
the select without the explicit for loop, maybe then you could use
appendChildren.

Bob - I had to use the full name of OPTION to get this to work; is
there a reason why SELECT is in the global namespace but OPTION is
not?  I started looking through the source for MochiKit.DOM but
haven't narrowed down why this is the case.

 - Kevin


On 10/25/06, Rodrigo Braga <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> Exists any function in form module to fill selects (html form element) with
> dictionaries contend key (value) and value (text) to options?
>
> example
>
> BlahModule.fillSelect(MyDic) where MyDic is ... {'value':1, 'text':'Test'}
> and html generated
> <select ... >
>       <option value="1">Test</option>
> </select>
>
> sorry my BAD english :)
>
>
>  ________________________________
>  Yahoo! Search
>  Música para ver e ouvir: You're Beautiful, do James Blunt
>  >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to