使用jQuery获取Servlet会话属性 [英] Get Servlet session attributes using jQuery
问题描述
我有一个抽奖按钮,根据我使用Servlet设置的会话属性启用或禁用。
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
-
enBancCount
等于零 - 这不是有效的一天
- the
enBancCount
is equals to zero - It's not a valid day
这是我的代码:
<button id="raffleBtn" type="submit"
${sessionScope.enBancCount == 0 || !sessionScope.validDay ? 'disabled' : ''}>
Raffle
</button>
我目前正在使用JSP EL添加已禁用$ c基于上述两个条件的按钮上的$ c>属性。但是现在,在启用它之前,我还必须检查是否有多数人参加了这个抽奖活动。
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
并将抽奖按钮的html更改为:
And changed the html for the raffle button to:
<button id="raffleBtn" type="submit" disabled>
Raffle
</button>
并添加了以下JQuery代码:
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');
}
});
我唯一的问题是我不知道如何获得 enBancCount
和 validDay
使用JQuery。
My only problem is that I don't know how to get the value of enBancCount
and validDay
using JQuery.
请帮帮忙?
推荐答案
你可以这样做
var enBancAccount = "${sessionScope.enBancCount}";
var validDay = "${sessionScope.validDay}";
这篇关于使用jQuery获取Servlet会话属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!