[Webinar] Streamline your web hosting managementRegister Today


How to get the value of a select item in Mootools

Posted on 2010-03-28
Medium Priority
Last Modified: 2013-11-11
I'm trying to get the value (not literally, I mean the text in-between the option tags inside the select) from a drop-down using Mootools and it is proving to be difficult. God I hate Mootools, but it is being used in a project I am working on.

The value I need has to be from the currently selected option. Your help is appreciated, thank you.
Question by:dwaynecharrington
LVL 22

Accepted Solution

remorina earned 750 total points
ID: 28942441
Hi Dwayn..,
It's simple, you just need to know the required event.

Below is an example of mootools getting the value when an option is selected.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
    <title>Mootools Example</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js"></script>
    <script type="text/javascript">
        window.addEvent( 'domready', function() {
            $('drop-down').addEvent( 'change', function getValue() {
                var value = this.get('value'); //Returns the myInput element's value.

    <select id="drop-down">
        <option value="Value 1">Value 1</option>
        <option value="Value 2">Value 2</option>
        <option value="Value 3">Value 3</option>
        <option value="Value 4">Value 4</option>

Open in new window

LVL 12

Assisted Solution

by:Avinash Zala
Avinash Zala earned 750 total points
ID: 28943775
Try attached code:

    var selectedValue = elem.get('value');

Open in new window


Author Closing Comment

ID: 31708202
Thank you for your help guys.

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

611 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question