开发者

How get all selected values (not empty) for all selects in Prototype $$()?

How get all selected values (not empty) for all selects in document using Prototype dollar dollar fu开发者_C百科nction $$() ?

Thanks, Celso


I don't know what your definition of "empty" is.

This needs to be known because most browsers will look at the value attribute as well as the text content of the option.

Assuming that there is a value attribute that has been set to an empty string, or there's no value and no text content, then you could do this:

var result = $$('select').invoke('getValue').without('');


One reason I switched to jQuery is that it is a lot easier to handle these situations.

You may need do it the hard way in Prototype:

$$('...').each(function(element) {
    if(element.innerHTML=='') {
        // your operation
    }

})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜