最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Get Servlet session attributes using jQuery - Stack Overflow

programmeradmin1浏览0评论

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}";
发布评论

评论列表(0)

  1. 暂无评论