尝试从输入字段

时间:2018-05-06 11:48:15

标签: java jquery

这是我的用户界面:

enter image description here

日期选择器功能的我的js文件:

$( function() {
    $( "#reportDateFrom" ).datepicker({ dateFormat : 'dd-M-yy' });
} );
$( function() {
    $( "#reportDateTo" ).datepicker({ dateFormat : 'dd-M-yy' });
} );

这是我的html页面:

<script type="text/javascript" src="/KGDLC_Report/resources/js/page- 
scripts/userWiseReportKGDLC.js"></script>
<div id="body">
        <fieldset>
            <legend>KGDLC Report</legend>
            <div id="box">
                <form  th:object="${posTable}" method="GET" >
                <p>
                    <label>Date From</label>
                    <input  type="text" id="reportDateFrom" /> 
                </p>
                <p>
                    <label>Date To</label>
                    <input  type="text" id="reportDateTo" /> 
                </p>
                <p>
                    <label>POS ID</label>
                    <select id="posId" th:field="*{posId}" >
                                <option value="">--</option>
                                <option th:each="pos : ${posIdList}"
                                th:value="${pos}"
                                th:utext="${pos}" />
                    </select>
                </p>
                <p> 
                <label>Report type</label>
                <select name="reportType" id="reportType">
                                <option value="pdf">PDF</option>
                                <option value="csv">CSV</option>
                                <option value="xls">XLS</option>
                                <option value="doc">DOC</option>
                </select>
                </p>
                <p>
                    <input class="formbutton" type="button" 
  onclick="reportPrintKGDLC()" value="View"/>
                </p>        
                </form>
            </div>
        </fieldset>
    </div>

点击view按钮后,reportPrintKGDLC()文件中的userWiseReportKGDLC.js方法正常运行。

我的userWiseReportKGDLC.js文件:

function reportPrintKGDLC() {
alert("inside js : reportPrintKGDLC()");
var outputFormat = $('#reportType').val();
var dateFrom = $('#reportDateFrom').val();
var dateTo = $('#reportDateTo').val();
var posId = $('#posId').val();

alert(outputFormat);
alert('dateFrom');
alert('dateTo');
alert(posId);

var myWindow = window.open("Print Preview.");
var html = "<div><h3>View</h3>" +
        "<iframe id='ifrmrptSummary' width='100%' height='100%'></iframe>" +
        "</div>";
var scriptCode = "myWindow<script type='text/javascript'>"+              
  " 
  document.getElementById('ifrmrptSummary').src= 
    '/KGDLC_Report/main/userWiseRepo          rtKGDLC? 
 dateFrom="+dateFrom+"&dateTo="+dateTo
     +"&outputFormat="+outputFormat+"&posId="+posId+"'</script>";
 myWindow.document.write("<html><head></head><body>" + html + scriptCode+ " 
 </body></html>");

};

然后我尝试读取从userWiseReportKGDLC.js文件发送到我的java文件的值,我将打印reprot。

@RequestMapping("/userWiseReportKGDLC")
public void viewReport(HttpServletRequest request, HttpServletResponse 
response) {
    System.out.println("/userWiseReportKGDCL");
    String dateFrom = request.getParameter("dateFrom");
    String dateTo = request.getParameter("dateTo");
    String outputFormat = request.getParameter("outputFormat");
    String posId = request.getParameter("posId");

    System.out.println("dateFrom: " + dateFrom);
    System.out.println("dateTo: "+dateTo);
    System.out.println("Output Format: " + outputFormat);
    System.out.println("posId: "+posId);

    Map<String,Object> param = new HashMap<String,Object>();
    param.put("dateFrom", dateFrom);
    param.put("dateTo", dateTo);
    param.put("posId", posId);

    String path = 

    request.getSession().getServletContext() 
   .getRealPath("/resources/jasper/POS_Report.jrxml");
    System.out.println(path);
    reportService.generateReport(path, outputFormat, param, response);
    System.out.println("After calling reportService.generateReport()");
}

我得到了outputFormat&amp;的准确值来自js文件的posId个值。但获得undefined&amp; dateFrom的值dateTo @echo off SET /P choice= What do you want me to do?: if %choice%==shutdown ( SET /P time= In how many minutes shall I shut down the computer?: set /a "time=%time%*60" shutdown -s -t "%time%" ) elseif ( ) 字段。不明白为什么。需要帮助。

0 个答案:

没有答案