js中的Scriptlet [英] Scriptlet in js
本文介绍了js中的Scriptlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个jsp页面...我正在根据请求参数动态添加一些内容(根据请求返回一个数组)基于此我必须创建一个下拉列表。我希望在更改另一个下拉菜单时这样做..所以可以使用javascript但我无法在js中使用scriptlet,这真的可能吗?
i have a jsp page... i am adding some content to page dynamically depending upon request parameters (an array will be returned by request) based on this i have to create a drop down. i want to do this on change of another drop down.. so can be done using javascript only but i am unable to use scriptlet in js, is this really possible??
编辑:我想对从scriptlet中检索到的值执行一些操作
EDIT : i wanna perform some actions on the values retrieved from scriptlet as well
它将属于这种类型
function changeMethod(){
var templateselected = document.getElementById("templateDropDown");
var versionDropDown = document.getElementById("versionDropDown");
if ( templateselected.options.selectedIndex != -1)
{
var selected=templateselected[templateselected.options.selectedIndex].value;
removeChildNodes(versionDropDown);
<%
RetrieveTempSecVersions[] lsListOfFiles = (RetrieveTempSecVersions []) request.getAttribute("templateNames") ;
for (int i=0 ; i < lsListOfFiles[1].getVersionNumber().length ; i++ ) {
System.out.println("helllooooo");%>
versionDropDown.innerHTML+='<OPTION VALUE="'+<%=lsListOfFiles[1].getVersionNumber()[i]%>+'">'+<%=lsListOfFiles[1].getVersionNumber()[i]%>+'</OPTION>';
<%}%>
}
}
推荐答案
是你可以有这样的东西
function addCombo() {
var textb = document.getElementById("txtCombo");
var combo = document.getElementById("combo");
var option = document.createElement("option");
<c:forEach var="state" items="${stateList}" varStatus="status">
option.text = "${state}";
option.value = "${state}";
try {
combo.add(option, null); //Standard
}catch(error) {
combo.add(option); // IE only
}
</c:forEach>
textb.value = "";
}
- 另见
- Also See
注意:我还没有测试过这段代码,这只是一个演示
Note: I haven't tested this code , this is just a demonstration
这篇关于js中的Scriptlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文