javascript - Get Servlet session attributes using jQuery - Stack Overflow

I have a raffle button that's being enabled or disabled based on Session Attributes I've set

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?

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?

Share edited Sep 5, 2014 at 6:11 lxcky asked Aug 25, 2014 at 6:05 lxckylxcky 1,6682 gold badges13 silver badges26 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

You can do like this

var enBancAccount = "${sessionScope.enBancCount}";
var validDay = "${sessionScope.validDay}";

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745050762a4608371.html

相关推荐

  • javascript - Get Servlet session attributes using jQuery - Stack Overflow

    I have a raffle button that's being enabled or disabled based on Session Attributes I've set

    22小时前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信