uniqezor
uniqezor

Reputation: 179

Identify an option from a select using jquery

I want to a client, choose a specific option, from a <select>, and that option has to do one thing:

Remove a class attribute "disabled", from <div id="addoptions" class="disabled">.

The value I want to get, when selected is: <option value="mobile">

I tried other posts, i saw some options and nothing worked for me.

Fiddle: https://jsfiddle.net/ujgx4st3/5/

HTML

   <select id="service">

                        <option selected="selected">Choose one of the options</option>

                        <optgroup label=""></optgroup>

                        <optgroup label="Web Development">
                            <option value="manage">Website Management</option>
                            <option value="update">Update to Responsive</option>
                            <option value="coding">Page Coding</option>
                            <option value="software">Software Programming</option>
                            <option value="mobile">Mobile Application</option>
                        </optgroup>

    </select></br></br>


    <div id="appoptions" class="col-md-3 disabled">

                        <div style="margin: 25px 0;">
                            <label><b>Application options</b> <small>(mobile)</small></label></br></br>

<input type="checkbox" name="platform" value="android" disabled>Android</br>
<input type="checkbox" name="platform" value="apple" disabled>Apple</br>
<input type="checkbox" name="platform" value="windows" disabled>Windows Phone</label></br>
<input type="checkbox" name="platform" value="webapp" disabled>Web application</br>
                        </div>
                    </div>


<div id="appoptions" class="col-md-3 disabled">

   <div style="margin: 25px 0">
        <label><b>Type of application</b></label></br></br>

<input type="checkbox" class="check" name="mobile" value="pay" disabled>Include payments options</br>

<input type="checkbox" class="check" name="mobile" value="users" disabled>Add registration</br>

<input type="checkbox" class="check" name="mobile" value="connect" disabled>Connected to Social Media</br>

<input type="checkbox" class="check" name="mobile" value="settings" disabled>Add app options</br>

     </div>
</div>

Upvotes: 0

Views: 40

Answers (2)

Spencer Wieczorek
Spencer Wieczorek

Reputation: 21575

You can do this in jQuery:

$("#service").change(function(){
    if( $(this).val() == "manage")
        $("#appoptions").removeClass("disabled");
});

For example, this will remove the disabled class on #appoptions when the option with the "manage" is selected. Which would be the one with the text "Website Management". Of course you could use "mobile" other than "manage" if you wish to.

Here is an example

Upvotes: 1

5eeker
5eeker

Reputation: 1027

Try this :

$("#service").change(function(){

    $("#appoptions").removeClass("disabled");


})

Upvotes: 0

Related Questions