根据下拉列表中选择的值加载表

时间:2017-01-04 06:57:27

标签: javascript java jsp

我有一个包含下拉列表的jsp。根据下拉列表中选择的值,我需要使用值在同一个jsp上填充表。

JSP:     

  <h3>Please select Platform:</h3>
  <select id="platforms" name="platforms">
   <option value=""></option>
   <%
    GetPathFromExcel getpathfromexcel=new GetPathFromExcel();
                        Set<String> platforms = new HashSet<String>();
                        platforms= getpathfromexcel.getPlatformColumn();
                        for (String s : platforms){
   %>
   <option value="<%=s%>"><%=s%></option>
   <%
    }
   %>
  </select>
  <h3>Please select Graph:</h3>
  <form name="form1">
   <div style="width: 300px; height: 500px; overflow: auto;">
    <table border="1" id="table">
     <thead>
      <th>Graph</th>
      <th><input id="selectAll" type="checkbox" title="Select All"
       onClick="checkall(this)"></th>
     </thead>

     <%
        Set<String> graphs = new HashSet<String>();
                            graphs=getpathfromexcel.getGraphs();
                            for(String g : graphs){
     %>
     <tr>
      <td><%=g%></td>
      <td><input name="select" type="checkbox" id=<%=g%>></td>
     </tr>
     <%
        }
     %>


    </table>
   </div>

   <input type="button" value="Submit" name="submit" id="submit" />
  </form>
 </div>

根据我在平台下拉列表中选择的值,我需要加载图表:

graphs=getpathfromexcel.getGraphs();

我显然可以通过以下方式获得所选平台的价值:

$("#platforms").change(function(){
        var platformSelected=$("#platforms").val();
    });

上面提到的代码显然不起作用,因为嵌入式Java代码将在服务器端运行,而Javascript位在客户端。我怎样才能让它发挥作用?

0 个答案:

没有答案