如何将输入类型值或id从一个jsp传递到另一个jsp页面

时间:2021-12-19 07:15:56

I want to book a online room at paticular date and time. For that I created one jsp page(entry.jsp) where I am selecting date(datepicker) and time. And in 2nd jsp page(checkRoom.jsp) I came to know which room is available.

我想在特定的日期和时间预订一个在线房间。为此我创建了一个jsp页面(entry.jsp),我选择了date(datepicker)和时间。在第二个jsp页面(checkRoom.jsp)中,我开始知道哪个房间可用。

So if I select available room then it will go to 3rd jsp page(roomDetails.jsp) where I am displaying date and time along with giving one input duration(from scrollable), so that I can calculate price of available room.

因此,如果我选择可用房间,那么它将转到第3个jsp页面(roomDetails.jsp),其中我显示日期和时间以及给出一个输入持续时间(来自可滚动),以便我可以计算可用房间的价格。

My question is how can I pass date id(#date from entry.jsp) to roomDetails.jsp because i have a method like calculatePrice('#date','#duration') in roomDetails m using postMessage to display price.

我的问题是如何将日期ID(来自entry.jsp的#date)传递给roomDetails.jsp,因为我在roomDetails m中使用了computePrice('#date','#duration')这样的方法,使用postMessage来显示价格。

In roomDeatils.jsp I have written like this method.

在roomDeatils.jsp中我写了这样的方法。

$(document).ready(function() {$("#date, #tickets_duration").change(calculateTotalPrice);  function calculateTotalPrice() {
    if ($("#tickets_duration").val() != "" && $("#date").val() != "") {
        if (window.Worker) {
            // create web worker
            var blob = new Blob(
                    [ document.querySelector("#worker").textContent ], {
                        type : 'text/javascript'
                    });
            var worker = new Worker(window.URL.createObjectURL(blob));

            worker.onmessage = function(event) {
                $("#total_price").html(event.data);
            }
            worker.onerror = function(errorObject) {
                $("#total_price").html("Error: " + errorObject.message);
            }
            var date = new Date($('#date').val());
                        alert(date);
            // get day
            var day = date.getDay();

            // get number of booked shows

            // send JSON data to worker                     
            var jsonData = {
                'day' : day,
                'tickets_duration' : Number($("#tickets_duration").val())
            };
            worker.postMessage(jsonData);
        }
    }
}

1 个解决方案

#1


0  

The jsp:forward action tag can help you with this.

jsp:forward action标签可以帮助你解决这个问题。

Just send in the variable and its value from one jsp to the other

只需将变量及其值从一个jsp发送到另一个jsp即可

#1


0  

The jsp:forward action tag can help you with this.

jsp:forward action标签可以帮助你解决这个问题。

Just send in the variable and its value from one jsp to the other

只需将变量及其值从一个jsp发送到另一个jsp即可