Skip to content
Permalink
Browse files

Added support for "first option is auto-selected in a drop-down" func…

…tionality.
  • Loading branch information
jeresig committed Jul 8, 2007
1 parent 52c6739 commit 6f0c9a5fd751d590be07e890758b8229e630413d
Showing with 21 additions and 0 deletions.
  1. +21 −0 build/runtest/env.js
@@ -305,6 +305,27 @@ var window = this;
set checked(val) { return this.setAttribute("checked",val); },

get selected() {
if ( !this._selectDone ) {
this._selectDone = true;

if ( this.nodeName == "OPTION" && !this.parentNode.getAttribute("multiple") ) {
var opt = this.parentNode.getElementsByTagName("option");

if ( this == opt[0] ) {
var select = true;

for ( var i = 1; i < opt.length; i++ )
if ( opt[i].selected ) {
select = false;
break;
}

if ( select )
this.selected = true;
}
}
}

var val = this.getAttribute("selected");
return val != "false" && !!val;
},

0 comments on commit 6f0c9a5

Please sign in to comment.
You can’t perform that action at this time.