使用 Jquery 和 for every 循环(用 scriptlet 编写)
我正在使用 Spring MVC 框架开发一个项目,目前正致力于弄清楚如何禁用从 foreach 循环(用 spriptlet 编写)生成的提交按钮。我知道 scriptlet 被认为是不好的做法,但我正在培训的公司似乎并不关心...
无论如何,这是我的 for 循环:
<%for(Aj aj : ajList) {%>
Job Name: <%=jobDao.getById(aj.getJobId()).getTitle() %><br/>
Current Status: <%=statusDao.getById(aj.getStatusId()).getStatusName() %><br/>
<input id="notQualified[<%=aj.getStatusId()%>]" class="notQualified[<%=aj.getStatusId()%>]" name="notQualified[<%=aj.getJobId() %>]" value="Not Qualified" type="submit" />
<input id="qualified[<%=aj.getStatusId()%>]" class="qualified[<%=aj.getStatusId()%>]" name="qualified[<%=aj.getJobId() %>]" value="Make Qualified" type="submit" />
<input id="interview[<%=aj.getStatusId()%>]" class="interview[<%=aj.getStatusId()%>]" name="interview[<%=aj.getJobId() %>]" value="Interview" type="submit" />
<input id="hire[<%=aj.getStatusId()%>]" class="hire[<%=aj.getStatusId()%>]" name="hire[<%=aj.getJobId() %>]" value="Hire" type="submit" /><br/><br/>
<%}%>
这是我迄今为止编写的 jquery:
$(function() {
$('.notQualified[<%=1%>]').attr('disabled', 'disabled');
$('.interview[<%=1%>]').attr('disabled', 'disabled');
$('.hire[<%=1%>]').attr('disabled', 'disabled');
$('.qualified[<%=2%>]').attr('disabled', 'disabled');
$('.interview[<%=2%>]').attr('disabled', 'disabled');
$('.notQualified[<%=3%>]').attr('disabled', 'disabled');
$('.qualified[<%=3%>]').attr('disabled', 'disabled');
$('.interview[<%=3%>]').attr('disabled', 'disabled');
$('.hire[<%=3%>]').attr('disabled', 'disabled');
$('.qualified[<%=4%>]').attr('disabled', 'disabled');
$('.hire[<%=4%>]').attr('disabled', 'disabled');
});
所以,如果它不清楚,我正在使用 4 种不同的状态。如果迭代的“aj”(数据库中的一个表,用于将用户与他们所申请的作业以及该用户的作业状态连接起来)对应于第一个状态,则禁用“不合格”、“面试”、和“雇用”按钮。等等,我将不胜感激任何帮助。
I am working on a project using the Spring MVC framework, and am currently stuck on figuring out how to disable submit buttons that have been produced from a for each loop (written in spriptlets). I know that scriptlets are considered bad practice, but the company I'm training at doesn't seem to care...
Anyways, here is my for loop:
<%for(Aj aj : ajList) {%>
Job Name: <%=jobDao.getById(aj.getJobId()).getTitle() %><br/>
Current Status: <%=statusDao.getById(aj.getStatusId()).getStatusName() %><br/>
<input id="notQualified[<%=aj.getStatusId()%>]" class="notQualified[<%=aj.getStatusId()%>]" name="notQualified[<%=aj.getJobId() %>]" value="Not Qualified" type="submit" />
<input id="qualified[<%=aj.getStatusId()%>]" class="qualified[<%=aj.getStatusId()%>]" name="qualified[<%=aj.getJobId() %>]" value="Make Qualified" type="submit" />
<input id="interview[<%=aj.getStatusId()%>]" class="interview[<%=aj.getStatusId()%>]" name="interview[<%=aj.getJobId() %>]" value="Interview" type="submit" />
<input id="hire[<%=aj.getStatusId()%>]" class="hire[<%=aj.getStatusId()%>]" name="hire[<%=aj.getJobId() %>]" value="Hire" type="submit" /><br/><br/>
<%}%>
And here is the jquery I've written thus far:
$(function() {
$('.notQualified[<%=1%>]').attr('disabled', 'disabled');
$('.interview[<%=1%>]').attr('disabled', 'disabled');
$('.hire[<%=1%>]').attr('disabled', 'disabled');
$('.qualified[<%=2%>]').attr('disabled', 'disabled');
$('.interview[<%=2%>]').attr('disabled', 'disabled');
$('.notQualified[<%=3%>]').attr('disabled', 'disabled');
$('.qualified[<%=3%>]').attr('disabled', 'disabled');
$('.interview[<%=3%>]').attr('disabled', 'disabled');
$('.hire[<%=3%>]').attr('disabled', 'disabled');
$('.qualified[<%=4%>]').attr('disabled', 'disabled');
$('.hire[<%=4%>]').attr('disabled', 'disabled');
});
So, if it isn't clear, I am working with 4 different statuses. If the "aj" (a table in the database that connects users with jobs they've applied to and the status of the job for that user) being iterated corresponds to the 1st status, disable the "not qualified," "interview," and "hire" buttons. Etc. I would appreciate any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到的麻烦来自状态 ID 周围的方括号。一旦我删除了它们,一切就正常了。
The trouble I was having came from the square brackets I had around the status id. Once I removed those, everything worked fine.