[英]How to include a variable JSP into a HTML label?
I have an JSP file, which is called from a button of a form in a HTML file. 我有一个JSP文件,可以从HTML文件中的表单按钮调用它。 In this JSP I get the option selected in a drop-downlist of the form, which is saved into the variable "topic".
在此JSP中,我从表单的下拉列表中选择了选项,该选项保存在变量“ topic”中。
In this JSP file I have another button that have to call the Javascript function crearframe(). 在此JSP文件中,我还有另一个按钮必须调用Javascript函数crearframe()。 The parameter have to be the value saved in the variable "topic".
该参数必须是保存在变量“ topic”中的值。 How can I do that?
我怎样才能做到这一点?
I need to open a different html file when the user press the button depending of the value of the variable "topic". 当用户按下按钮时,我需要打开另一个HTML文件,具体取决于变量“ topic”的值。 The name of the html file will be "topicValue" + ".html".
html文件的名称将为“ topicValue” +“ .html”。
Is there any way of doing this? 有什么办法吗?
Thank you very much. 非常感谢你。
Here is the code. 这是代码。
<script language="javascript">
function crearframe(htmlFilePath) {
var testframe = document.getElementById("iframe");
testframe.src = htmlFilePath + ".html";
}
</script>
</head>
<body>
<table width="100%">
<tr>
<td align="center" valign="top">
<%
String topic = request.getParameter("opcion");
out.println("<H2>Resultado del análisis sobre " + topic + "</H2>");
%>
<div id="grafica"></div>
<table width="80%">
<tr>
<td align="center" width="25%">
<button type="button" name="Analizar1" class="btn btn-primary" Onclick="crearframe('HaveToBeTheTopicVariable')" >Ver;</button>
Do in this way using Scriptlets 使用Scriptlets以这种方式进行
Onclick="crearframe('<%= topic %>')"
I never suggest you to use Scriptlets instead use JSP Standard Tag Library . 我从不建议您使用Scriptlets而不是JSP标准标记库 。
Have a look at How to avoid Java Code in JSP-Files? 看看如何避免JSP文件中的Java代码?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.