在HTML中选择标记,如何检查选择了哪个选项

时间:2022-11-26 23:44:30

I have a select tag with a bunch of option tags and I want to use JSTL to check which option has been selected but not sure where to begin. If I select one of the options then I need the JSTL to check it but that only runs when the page reloads so if I reload the page, then the option is reset to default. So how would I send a value to the JSTL code?

我有一个带有一堆选项标签的select标签,我想使用JSTL来检查哪个选项已被选中但不知道从哪里开始。如果我选择其中一个选项,那么我需要JSTL来检查它,但只在页面重新加载时运行,所以如果我重新加载页面,那么该选项将重置为默认值。那么如何将值发送到JSTL代码?

I have done this option by using:

我使用以下方法完成了此选项:

<input type="submit" name="SignInButton" value="Sign In" />
<input type="hidden" name="submitted" value="true" />

for buttons for example and then using something like this:

例如按钮然后使用这样的东西:

<c:when test="${param.SigningOut == 'true' && sessionScope.SignedIn == 'true'}">

To check it but I don't know how to do it for multiple options in a down list using

要检查它,但我不知道如何使用向下列表中的多个选项

I hope it makes sense what I am trying to do. Thanks for reading.

我希望我想要做的事情是有意义的。谢谢阅读。

1 个解决方案

#1


0  

JSTL runs on server side, so you cannot validate nor process any data in client using JSTL nor any other JSP tag. Note that scriptlets also run on server side, so it is not an option either.

JSTL在服务器端运行,因此您无法使用JSTL或任何其他JSP标记验证或处理客户端中的任何数据。请注意,scriptlet也在服务器端运行,因此它也不是一个选项。

If you want/need to perform any validation, action, effect, etc. on client side, use Javascript. Either if you need to validate the data on server side, you can use ajax for better user experience within your web application.

如果您想/需要在客户端执行任何验证,操作,效果等,请使用Javascript。如果您需要验证服务器端的数据,可以使用ajax在Web应用程序中获得更好的用户体验。

#1


0  

JSTL runs on server side, so you cannot validate nor process any data in client using JSTL nor any other JSP tag. Note that scriptlets also run on server side, so it is not an option either.

JSTL在服务器端运行,因此您无法使用JSTL或任何其他JSP标记验证或处理客户端中的任何数据。请注意,scriptlet也在服务器端运行,因此它也不是一个选项。

If you want/need to perform any validation, action, effect, etc. on client side, use Javascript. Either if you need to validate the data on server side, you can use ajax for better user experience within your web application.

如果您想/需要在客户端执行任何验证,操作,效果等,请使用Javascript。如果您需要验证服务器端的数据,可以使用ajax在Web应用程序中获得更好的用户体验。