File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 575
575
}
576
576
self . option = function ( name , value ) {
577
577
var index ;
578
+ //see if there is already an option with this name
578
579
for ( var i = 0 ; i < this . elt . length ; i ++ ) {
579
580
if ( this . elt [ i ] . innerHTML == name ) {
580
- index = i ;
581
- break ;
581
+ index = i ;
582
+ break ;
582
583
}
583
584
}
585
+ //if there is an option with this name we will modify it
584
586
if ( index !== undefined ) {
587
+ //if the user passed in false then delete that option
585
588
if ( value === false ) {
586
589
this . elt . remove ( index ) ;
587
590
} else {
591
+ //otherwise if the name and value are the same then change both
588
592
if ( this . elt [ index ] . innerHTML == this . elt [ index ] . value ) {
589
593
this . elt [ index ] . innerHTML = this . elt [ index ] . value = value ;
594
+ //otherwise just change the value
590
595
} else {
591
596
this . elt [ index ] . value = value ;
592
597
}
593
598
}
594
599
}
600
+ //if it doesn't exist make it
595
601
else {
596
602
var opt = document . createElement ( 'option' ) ;
597
603
opt . innerHTML = name ;
You can’t perform that action at this time.
0 commit comments