I have a form that have input element and the select element with multi select. so how can I set value for the input element and select element in mootools.
basically - element.get("value");
returns the value for all inputs, selects and textareas, .set("value", value);
to set them (except for multiples)
it's more complicated for select with multiple - the above returns the FIRST selected only, you need to do element.getSelected().get("value")
to recieve an array of values (.getSelected() on its own will return the pointers to the actual option
elements)
and finally, to set multiple selections, only way i can think of atm is to write your own element prototype that walks through child nodes with the values as specified and does .set("selected", "selected")
let me know if you need any help writing the latter
For dropdown:
$('idOfSelect').selectedIndex = x;
For text:
$('IdOfInput').value = 'Foo';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With