0

我正在尝试从下面的表单中生成一个特定的 url。会有一个日历,日期将进入网址。也是来自 9 种票类型和每张票的数量的值。所以我的网址看起来像这样

https://sales.site.com/?action=quicksale&venueid=1&businessdate=2012-10-05&ticketids=6,8&quantities=1,1

使用这些值:action:总是“quicksale”,venueid:总是“1”,businessdate:请求的销售日期;可以是 mm-dd-yyyy 或 yyyy-mm-dd,ticketids:见下表,数量:按ticketid 列出的顺序。

我将如何解决这个问题,我应该使用 php 还是 jquery?发布或获取。日历应该是 Jquery 吗?

求建议,谢谢

                        <form method="post" action="">-->
            <div class="quick-book-form-elements">
                <table width="255" class="quick-book-table" cellpadding="4">
                    <tbody>
                        <tr class="quick-book-days">
                            <th>&nbsp;</th>
                            <th><img src="../public/img/1day-small.png" alt="" /></th>
                            <th><img src="../public/img/2day-small.png" alt="" /></th>
                            <th class="quick-book-last"><img src="../public/img/3day-small.png" alt="" /></th>
                        </tr>

                        <tr class="quick-book-adults">
                            <th class="quick-book-labels">
                                Adult
                            </th>
                            <td>
                                <div class="ticket-style-quick-book">
                                    <select class="adult-ticket-select">
                                        <option value="0">0</option>
                                        <option value="1">1</option>
                                    </select>
                                    <span class="quick-book-price">$40/ea</span>
                                </div>
                            </td>

                            <td>
                                <div class="ticket-style-quick-book">
                                    <select class="adult-ticket-select">
                                        <option value="0">0</option>
                                        <option value="1">1</option>
                                    </select>
                                    <span class="quick-book-price">$50/ea</span>
                                </div>
                            </td>
                            <td class="quick-book-last">
                                <div class="ticket-style-quick-book">
                                    <select class="adult-ticket-select">
                                        <option value="0">0</option>
                                        <option value="1">1</option>
                                    </select>
                                    <span class="quick-book-price">$60/ea</span>
                                </div>
                            </td>
                        </tr>

                        <tr class="quick-book-child">
                            <th class="quick-book-labels">Child</th>
                            <td>
                                <div class="ticket-style-quick-book">
                                    <select class="adult-ticket-select">
                                        <option value="0">0</option>
                                        <option value="1">1</option>
                                    </select>
                                    <span class="quick-book-price">$30/ea</span>
                                </div>
                            </td>
                            <td>
                                <div class="ticket-style-quick-book">
                                    <select class="adult-ticket-select">
                                        <option value="0">0</option>
                                        <option value="1">1</option>
                                    </select>
                                    <span class="quick-book-price">$40/ea</span>
                                </div>
                            </td>
                            <td class="quick-book-last">
                                <div class="ticket-style-quick-book">
                                    <select class="adult-ticket-select">
                                        <option value="0">0</option>
                                        <option value="1">1</option>
                                    </select>
                                    <span class="quick-book-price">$50/ea</span>
                                </div>
                            </td>
                        </tr>

                        <tr class="quick-book-family">
                            <th class="quick-book-labels">Family</th>
                            <td>
                                <div class="ticket-style-quick-book">
                                    <select class="adult-ticket-select">
                                        <option value="0">0</option>
                                        <option value="1">1</option>
                                    </select>
                                    <span class="quick-book-price">$125/ea</span>
                                </div>
                            </td>
                            <td>
                                <div class="ticket-style-quick-book">
                                    <select class="adult-ticket-select">
                                        <option value="0">0</option>
                                        <option value="1">1</option>
                                    </select>
                                    <span class="quick-book-price">$155/ea</span>
                                </div>
                            </td>
                            <td class="quick-book-last">
                                <div class="ticket-style-quick-book">
                                    <select class="adult-ticket-select">
                                        <option value="0">0</option>
                                        <option value="1">1</option>
                                    </select>
                                    <span class="quick-book-price">$185/ea</span>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        <a href="http://sales.site.com/" title="" class="quick-book-submit-btn"></a>
        <input type="submit" class="quick-book-submit-btn" name="quick-book-submit-btn" value="" />
    </form>
</div><!-- end quick-book-form div -->

4

1 回答 1

0

对于日历,确实可以使用 jQuery-ui 之一。这是一个很好的小部件,易于配置且非常强大。

http://jqueryui.com/demos/datepicker/

您可以将其配置为将您想要的格式放入输入中(例如 YYYY-MM-DD)

最后,您应该在提交事件上添加一个侦听器,以执行您的操作修改:

// This function will be call before the submit
$("#YOUR_FORM_ID").submit(function(submitEvent) {

    // Initialize the query param array
    var queryParams = [];

    // Fill the query param with values
    queryParams.push("action=quicksale");
    queryParams.push("venueid=1");
    queryParams.push("businessdate=" + $("#YOUR_INPUT_DATE_ID").val());
    // etc...

    // Finally update the form action
    $(this).attr('action', 'https://sales.site.com/?' + queryParams.join("&"));

    // The action has been updated
    // The submit will process
});
于 2012-10-03T22:30:25.183 回答