PDA

View Full Version : Setting dropdowns when using DomHelper.Template



hady
2 Dec 2006, 2:56 AM
I have a template that gets populated using a YAHOO.ext.DomHelper.Template object. The template is a form that contains input fields and select fields.

I need to be able to set a particular option for a drop down select field. Any ideas how this could be done?

I am thinking of doing this using a Javascript function or something?

Animal
2 Dec 2006, 3:07 AM
Template can have parameters which are inserted at element creation time: http://www.jackslocum.com/blog/2006/10/06/domhelper-create-elements-using-dom-html-fragments-or-templates/

hady
2 Dec 2006, 3:37 AM
Yes... but you missed the point.

A dropdown menu item in HTML is something like this:



<select>
<option>Option1</option>
<option>Option2</option> //the selected keyword in the option tag is not being shown
<option>Option3</option>
</select>

So I am trying to figure out a way of inserting the word 'selected' for the option type that should be selected.

Animal
2 Dec 2006, 4:46 AM
Use selected="{0}" and set the parameter to 'true' or 'false'. Should work.. I think :?