douli2063 2016-08-05 07:53
浏览 22

我想将总计数器和计数器值传递给文本框中的另一个php页面并保存到数据库?

I want to pass total and counter value to another PHP page in a text box and save to database.

{
    var price =10;

    //price
    $(document).ready(function() {
        var $cart = $('#selected-seats'),  //Sitting Area
            $counter = $('#counter'),  //Votes
            $total = $('#total');  //Total money

        var sc = $('#seat-map').seatCharts({
                map: [  //Seating chart
                        '_______a',
                        '________',
                        'aa____aa',
                        'aa____aa',
                        'aa____aa',
                        'aa____aa',
                        'aa____aa',
                        'aa____aa',
                        'aa____aa',
                        'aa____aa',
                        'aa____aa'
                ],
                naming: {
                    top: false,
                    getLabel: function (character, row, column) {
                        return column;
                    }
                },
                legend: { //Definition legend
                    node: $('#legend'),
                    items: [
                        [ 'a', 'available','Available' ],               
                        [ 'a', 'unavailable', 'Booked']
                    ]                   
                },
                click: function () { //Click event
                    if (this.status() == 'available') { //optional seat
                        $('<li>R'+(this.settings.row+1)+' S'+this.settings.label+'</li>')
                            .attr('id', 'cart-item-'+this.settings.id)
                            .data('seatId', this.settings.id)
                            .appendTo($cart);

                        $counter.text(sc.find('selected').length+1);
                        $total.text(recalculateTotal(sc)+price);

                        return 'selected';
                    } else if (this.status() == 'selected') { //Checked
                        //Update Number
                        $counter.text(sc.find('selected').length-1);

                        //update totalnum
                        $total.text(recalculateTotal(sc)-price);

                        //Delete reservation
                        $('#cart-item-'+this.settings.id).remove();
                        //optional
                        return 'available';
                    } else if (this.status() == 'unavailable') { //sold
                        return 'unavailable';
                    } else {
                        return this.style();
                    }
                }
        });

        //sold seat
        sc.get(['1_8','4_4','4_5','6_6','6_7','8_5','8_6','8_7','8_8','10_1', '10_2']).status('unavailable');   
    });

    //sum total money
    function recalculateTotal(sc) {
        var total = 0;
        sc.find('selected').each(function () {
            total += price;
        }); 

        return total;  //here returning total amount
    }
}
  • 写回答

1条回答 默认 最新

  • dongpeng0127 2016-08-05 09:32
    关注
    // You can use this "Javascript" code to navigate to the next page
    window.location = "savetodbpage.php?total=" + $total + "&counter=" + $counter
    
    // PHP To receive the params
    <?php
    $total = @$_GET[ "total" ];
    $counter = @$_GET[ "counter" ];
    
    // Below you can either update / insert these values into your database. You have not mentioned much in your question so this is how far I can go helping you. Look up on SQL Insert / Update queries depending on what you actually want to do...
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图