Link to home
Start Free TrialLog in
Avatar of Arikkan
ArikkanFlag for United States of America

asked on

Selecting from buttons

Hi,

------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I have the following code in my page:

<h3>Filter By</h3>

@for (int n = 1; n < 4; n++)
 {

<div class="control-group">
<div class="control-label">

 <div class="input-append">
    <select class="clause-selector gen-clauses">
            <option value="">@Translations.lang.select</option>
    </select>
        <button id="alpha-list" class="btn clause-list" type="button">
            <i class="icon-list"></i>
        </button>
        <button id="grouped-list" style="display:none" class="btn clause-list" type="button">
            <i class="icon-cat"></i>
        </button>
 </div>

</div>
</div>

}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------


the two buttons toggle using the following JQUERY code:

    $('.clause-list').on("click", function (event) {
        var other = $(this).siblings('.clause-list').first();
        buildSearchClauses($(this).prevAll('.clause-selector').first(), (this.id !== 'alpha-list'));
        $(this).hide();
        other.show();
    });

------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Now I want to write a JQUERY statement to get the Button selected by the user at the moment. Then I want to use it to do some action (Something like this):

function PerformActionOnButtonStatus()
{
     $('select.gen-clauses').each(function (key, sel)
    {    
     var selectedStatus = $(this).children('button').filter("button:selected").text();  //Can you help
     var sel = Selected Button object;  //Can you help
     
     if(selectedStatus = 'grouped')   //Grouped means that I selected button with id="alpha-list"
         { CallFunction1(sel, true); }
    else
         { CallFunction1(sel, false); }

    }
}    
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ASKER CERTIFIED SOLUTION
Avatar of David S.
David S.
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Arikkan

ASKER

It is a CSHTML and I am not very familiar with that.
I am just modifying some code done earlier.

But this works right:
        $(this).hide();
        other.show();

So, what do I need to add to the buttons to make sure I can read their selected state?