I have a raffle button that's being enabled or disabled based on Session Attributes I've set using Servlets.
It should be disabled if either of this is true
- the
enBancCount
is equals to zero - It's not a valid day
Here is my code:
<button id="raffleBtn" type="submit"
${sessionScope.enBancCount == 0 || !sessionScope.validDay ? 'disabled' : ''}>
Raffle
</button>
I'm currently using JSP EL to add the disabled
attribute on the button based on the two conditions above. But now, before enabling it, I also have to check if majority attended on this raffle.
I added the following input fields for checking the attendance:
<input type="checkbox" name="attendance" value=""> ATTENDEE 1
<input type="checkbox" name="attendance" value=""> ATTENDEE 2
<input type="checkbox" name="attendance" value=""> ATTENDEE ...
<input type="checkbox" name="attendance" value=""> ATTENDEE 6
And changed the html for the raffle button to:
<button id="raffleBtn" type="submit" disabled>
Raffle
</button>
And added the following JQuery code:
$('[name=attendance]').change(function() {
if ($('[name=attendance]:checked').length >= 4
&& // CONDITION IF ENBANC CASE IS NOT ZERO
&& // CONDITION IF IT'S A VALID DAY) {
$('#raffleBtn').removeAttr('disabled');
} else {
$('#raffleBtn').attr('disabled', 'disabled');
}
});
My only problem is that I don't know how to get the value of enBancCount
and validDay
using JQuery.
Please help?
I have a raffle button that's being enabled or disabled based on Session Attributes I've set using Servlets.
It should be disabled if either of this is true
- the
enBancCount
is equals to zero - It's not a valid day
Here is my code:
<button id="raffleBtn" type="submit"
${sessionScope.enBancCount == 0 || !sessionScope.validDay ? 'disabled' : ''}>
Raffle
</button>
I'm currently using JSP EL to add the disabled
attribute on the button based on the two conditions above. But now, before enabling it, I also have to check if majority attended on this raffle.
I added the following input fields for checking the attendance:
<input type="checkbox" name="attendance" value=""> ATTENDEE 1
<input type="checkbox" name="attendance" value=""> ATTENDEE 2
<input type="checkbox" name="attendance" value=""> ATTENDEE ...
<input type="checkbox" name="attendance" value=""> ATTENDEE 6
And changed the html for the raffle button to:
<button id="raffleBtn" type="submit" disabled>
Raffle
</button>
And added the following JQuery code:
$('[name=attendance]').change(function() {
if ($('[name=attendance]:checked').length >= 4
&& // CONDITION IF ENBANC CASE IS NOT ZERO
&& // CONDITION IF IT'S A VALID DAY) {
$('#raffleBtn').removeAttr('disabled');
} else {
$('#raffleBtn').attr('disabled', 'disabled');
}
});
My only problem is that I don't know how to get the value of enBancCount
and validDay
using JQuery.
Please help?
Share edited Sep 5, 2014 at 6:11 lxcky asked Aug 25, 2014 at 6:05 lxckylxcky 1,6682 gold badges13 silver badges26 bronze badges1 Answer
Reset to default 2You can do like this
var enBancAccount = "${sessionScope.enBancCount}";
var validDay = "${sessionScope.validDay}";