I have the following code of an input text fetching value from a dropdown.I want to fetach the current value from input to match with map.key for my work.How to go about it
我有一个输入文本的下面代码从下拉列表获取值。我想从输入中获取当前值以匹配我的工作map.key。如何去做
<div class="dropdown">
<div class="input-group">
<input type="Text" ID="datebox6" Class="form-control" value=10001 name="uid"></input>
<div class="input-group-btn">
<b>Select Store</b><br>
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu6" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu6">
<c:forEach var="Employee_id" items="${obj.dataEmp}">
<li>
<a>${Employee_id}</a>
</li>
</c:forEach>
</ul>
</div>
</div>
</div>
</div>
</form>
</div>
<div class="col-sm-3 col-sm-offset-1">
<b>
<h5>Employee ID:</h5>
</b>
<c:out value="${param.uid}" />
<c:forEach var="map" items="${obj.dataEmployee}" varStatus="status">
<c:if test="${map.key==10002}">
${map.key}<br>
Age:
${map.value[1]}
</c:if>
</c:forEach>
</div>
1 个解决方案
#1
1
There's a fundamental misunderstanding here: Your JSP using JSTL runs on the server, before the HTML is sent to the client's browser. The input has a "current value" only later, on the client's browser, long after your server-side code has stopped running.
这里存在一个根本性的误解:在将HTML发送到客户端的浏览器之前,使用JSTL的JSP在服务器上运行。在服务器端代码停止运行很久之后,输入在客户端浏览器上稍后才会显示“当前值”。
If you want to make the page update dynamically using client-side information, you'll need to use a client-side technology (JavaScript combined with the DOM, directly or indirectly through a library like jQuery and/or a templating engine like Handlebars and/or an MVVM or MVC library/framework like ReactJS, Knockout, RivetsJS, etc.).
如果您想使用客户端信息动态更新页面,则需要使用客户端技术(JavaScript与DOM结合,直接或间接通过jQuery等库和/或像Handlebars这样的模板引擎/或MVVM或MVC库/框架,如ReactJS,Knockout,RivetsJS等)。
If you want to refresh the page with information from the client, you'll need to have a form post back to a JSP which receives the information as parameters and then generates a new page to send back to the browser.
如果要使用来自客户端的信息刷新页面,则需要将表单发回到JSP,该JSP将接收信息作为参数,然后生成新页面以发送回浏览器。
#1
1
There's a fundamental misunderstanding here: Your JSP using JSTL runs on the server, before the HTML is sent to the client's browser. The input has a "current value" only later, on the client's browser, long after your server-side code has stopped running.
这里存在一个根本性的误解:在将HTML发送到客户端的浏览器之前,使用JSTL的JSP在服务器上运行。在服务器端代码停止运行很久之后,输入在客户端浏览器上稍后才会显示“当前值”。
If you want to make the page update dynamically using client-side information, you'll need to use a client-side technology (JavaScript combined with the DOM, directly or indirectly through a library like jQuery and/or a templating engine like Handlebars and/or an MVVM or MVC library/framework like ReactJS, Knockout, RivetsJS, etc.).
如果您想使用客户端信息动态更新页面,则需要使用客户端技术(JavaScript与DOM结合,直接或间接通过jQuery等库和/或像Handlebars这样的模板引擎/或MVVM或MVC库/框架,如ReactJS,Knockout,RivetsJS等)。
If you want to refresh the page with information from the client, you'll need to have a form post back to a JSP which receives the information as parameters and then generates a new page to send back to the browser.
如果要使用来自客户端的信息刷新页面,则需要将表单发回到JSP,该JSP将接收信息作为参数,然后生成新页面以发送回浏览器。