Prototype set selected option based on other select

Posted by xain on Stack Overflow See other posts from Stack Overflow or by xain
Published on 2010-04-13T13:48:57Z Indexed on 2010/04/13 13:53 UTC
Read the original article Hit count: 207

Filed under:
|
|

Hi, how can I "copy" the selected option between two s that have the same options using prototype ? I tried getting the selected option from the "master" combo using

function getSelectedArea() {
  $$('#areacont1 option').find(function(ele){return !!ele.selected})
}

which returns null

And setting the second combo using

var c2ROptions = $$('select#areacont2 option')
c2ROptions[getSelectedArea()].selected = true

That obviously doesn't work because the function returns null.

Any hints?

Thanks.

© Stack Overflow or respective owner

Related posts about prototype

Related posts about select