I am trying to learn MooTools and I ALWAYS ARE javascript noobie, so please be careful with me.
What I'm going to do is to change the state of the forbidden input field (type is text) when a specific parameter is selected. The html is a bit like tis:
<select class="wide" id="selectBox" name="option>
<optgroup label="Common">
<option value="one">One<option>
<option value="two">Two<option>
<option value="three">Three<option>
</optgroup>
<optgroup label="Less Common">
<option value="other">Other<option>
</optgroup>
</select>
<input id="other" type="text" disabled="disabled" />
This is what I was HOPING, would give me a value that needs to be checked in the if statement, which would then change the input disabled to enabled:
window.addEvent('domready', function(){
$$('#selectBox').addEvent('change',function(){
var selection = $$('#selectBox').getSelected();
alert(selection);
});
});
When we run the code (i.e., select a different value in the selection window), all I get is that [object HTMLOptionElement].
The mootools documentation for this method is SPARSE and only says:
Element Method: getSelected
Returns the selected options, select an item.
Returns:
* (array) An array of the selected elements.
Examples: HTML
<select id="country-select" name="country">
<option value="US">United States</option
<option value ="IT">Italy</option>
</select>
Javascript
$('country-select').getSelected();
Note:
, select. , .
!
-, , , . :
var selection = $$('#selectBox').getSelected().value;
var selection = $$('#selectBox').getSelected('value');
var selection = $$('#selectBox').getSelected();
alert(selection[0]);
. undefined, [object HTMLOptionElement].