Arikkan
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.lan g.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("clic k", function (event) {
var other = $(this).siblings('.clause- list').fir st();
buildSearchClauses($(this) .prevAll(' .clause-se lector').f irst(), (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 PerformActionOnButtonStatu s()
{
$('select.gen-clauses').ea ch(functio n (key, sel)
{
var selectedStatus = $(this).children('button') .filter("b utton:sele cted").tex t(); //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); }
}
}
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --
--------------------------
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.lan
</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("clic
var other = $(this).siblings('.clause-
buildSearchClauses($(this)
$(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 PerformActionOnButtonStatu
{
$('select.gen-clauses').ea
{
var selectedStatus = $(this).children('button')
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?