dqpkea9486 2015-10-30 17:00
浏览 52

传递由角函数获得的php post变量

This is my code:

<form role="form" action="foo.php" method="post">
                        <p ng-repeat="item in selectedItems | orderBy: 'ora'">
                            Campo numero: {{item.id}} Orario: {{item.ora}}:00 Prezzo: €{{prezzoOra()}}.00
                        </p>
                        <p>
                            <b>Ore totali:</b> {{selectedItems.length}}<br>
                            <b>Prezzo Totale:</b> €{{total(selectedItems)}}.00
                        </p>
                        <input type="hidden" value="{{total(selectedItems)}}" name="totale" id="totale" />
                        <button type="button" class="btn btn-default" data-dismiss="modal">Indietro</button>

                        <input type="submit" value="Procedi con il pagamento" ng-click="prenota(selectedItems)" class="btn btn-primary">
</form>

When i try to get the $_POST['totale'] in the foo.php page the result that i obtain is always 0.

prenota function:

$scope.prenota = function(selectedItems) {

    for(var i = 0, len = $scope.selectedItems.length; i < len; i++) {

        var id = selectedItems[i].id;
        var ora = selectedItems[i].ora;

        $http.post(base_path + "prenotazione/campi/prenota", {'id': id, 'ora': ora, 'data': $scope.data}).success(function(data,status,headers,config){

            $scope.myPromise =  $http.post(base_path + "prenotazione/campi/data", {'data': $scope.data}).success(function(data,status,headers,config){
                                    $scope.disponibilita = data;
                                });
        });

    }


    $scope.selectedItems = [];

};

What's the problem?

  • 写回答

1条回答 默认 最新

  • dream_high1026 2015-10-30 19:31
    关注

    I'm not sure that it will work with the value set like that. And then set the input using an ng-value (AngularJS >=v1.2) instead of interpolating the scope.

    <input type="hidden" ng-value="total(selectedItems)" name="totale" id="totale" />
    

    Also, are you using the native form submission from the browser or are you posting through an ajax request in the function prenota? It could help to know the contents of this function.

    评论

报告相同问题?

悬赏问题

  • ¥20 关于多单片机模块化的一些问题
  • ¥30 seata使用出现报错,其他服务找不到seata
  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取
  • ¥15 vue3+element-plus页面崩溃
  • ¥15 像这种代码要怎么跑起来?
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection