0

我有以下 jsp 页面,当我选择 MYAP_FORM 时,我希望显示隐藏的表单,但事实并非如此。

现在我只有一个没有显示的表单,我将添加更多,并根据选择显示正确的一个。

任何输入为什么我看不到相应的表单显示...

谢谢

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.io.*"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="url">${pageContext.request.requestURL}</c:set>
<c:set var="baseURL" value="${fn:replace(url, pageContext.request.requestURI, pageContext.request.contextPath)}" />

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="${baseURL}/bootstrap/css/bootstrap.css">
<title>Testing</title>
</head>
<body>
    <script src="${baseURL}/bootstrap/js/bootstrap.js"></script>

        <form id="platform" class="container text-center">
        <select id="myselect">
        <option value="" selected="selected"></option>
        <option value="MYAP_FORM">MYAP_FORM</option>
        <option value="XYZ_FORM">XYZ_FORM</option>
        </select>
        </form>

    <%
        String file = application.getRealPath("/") + "xzyFiles.txt";
        FileInputStream fis = new FileInputStream(file);
        BufferedReader br = new BufferedReader(new InputStreamReader(fis)); 
        String tmp;



        out.println("<form class=\"container\" id=\"MYAP_FORM\" style=\"display:none\">");
        while ((tmp = br.readLine()) != null) {
           out.print("<label class=\"checkbox text-left\">");
           out.print("<input type=\"checkbox\" id=\"" + tmp +"\" value=\"1\">" + tmp + "</BR>");
           out.print("</label>");
        }       
        fis.close();
        out.println("<button class=\"btn btn-primary\">Submit</button>");
        out.println("<button class=\"btn btn-primary\">Clear</button>");
        out.println("</form>");
    %>

    <script>
    $("#myselect").on("change", function() {
        $("#" + $(this).val()).show();
    })
    </script>
</body>
</html>
4

1 回答 1

0

缺少 JQuery 脚本,一旦添加它就可以正常工作。

于 2013-11-14T20:35:22.617 回答