Thing one
Thing two
Other...
Thing three
Thing four
Other...
document.observe('dom:loaded',function(){ var combo = function(evt){ var elm = evt.element(); if ($F(elm) == 'Other...'){ var w = elm.getWidth() + 'px'; var theId = elm.id; var txt = new Element('input', { type:'text', id:theId }).clonePosition(elm,{setHeight:false}); if(!window.comboBackup) window.comboBackup = new Object(); window.comboBackup[theId] = Element.replace(elm,txt); $(theId).activate().observe('blur',function(e){ var t = e.element(); if($F(t) == t.defaultValue){ t.replace(window.comboBackup[theId]); $(theId).options.selectedIndex = 0; } }); } } $$('select.combo').invoke('observe','change',combo); });