1

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

  1. the enBancCount is equals to zero
  2. 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?

1 Answer 1

2

You can do like this

var enBancAccount = "${sessionScope.enBancCount}";
var validDay = "${sessionScope.validDay}";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.