Problems with PHP+ jquery

Asked

Viewed 36 times

0

How do I take a value from a button in jquery and move to another page?

My problem is to pass the data of the request I received from the bank and make this data appear on another page and I want to do through this boot +:

inserir a descrição da imagem aqui

knife-your-request.php

<div class="container">
            <div class="heading step-head text-center padding-top-25 padding-bottom-25 margin-bottom-0">
                <span><?php echo $rsCat['categoria_nome']; ?></span>
            </div>
            <?php
            $sqlSubcat =  "select subcategoria_id, subcategoria_nome from subcategoria where subcategoria_habilitado='1' and subcategoria_ativo='1' and categoria_id='".$rsCat['categoria_id']."'";
            $tbSubcat = mysql_query($sqlSubcat) or die(mysql_error());

            if(mysql_num_rows($tbSubcat) > 0){
                while($rsSubcat = mysql_fetch_array($tbSubcat)){
            ?>
                    <h6 class="step-head text-center padding-bottom-10"><?php echo $rsSubcat['subcategoria_nome']; ?></h6>
                    <ul class="pizza-flavers">
                        <?php
                        $sqlItem = "select item_id, item_nome, item_descricao, item_preco from item where item_habilitado='1' and item_ativo='1' and categoria_id='".$rsCat['categoria_id']."' and subcategoria_id='".$rsSubcat['subcategoria_id']."' order by item_nome";
                        $tbItem = mysql_query($sqlItem) or die(mysql_error());
                        if(mysql_num_rows($tbItem) > 0){
                            $i=1;
                            while($rsItem = mysql_fetch_array($tbItem)){

                        ?>
                        <li>

It selects the item, and the inputs, the problem is: when I click on the + I want it to identify it and when I click on the finish it should appear with this data that I solved on another page:

Javascript of the button "+"

$(document).ready(function() {

  $(".pizza-add-sub").append('<div class="plus qty-pizza">+</div><div class="mines qty-pizza">-</div>');
  $(".qty-pizza").on("click", function() {

    var $button = $(this);
    var oldValue = $button.parent().find("input").val();
    if ($button.text() == "+") {
      var newVal = parseFloat(oldValue) + 1;
    } else {
      // Don't allow decrementing below zero
      if (oldValue > 0) {
        var newVal = parseFloat(oldValue) - 1;
      } else {
        newVal = 0;
      }
    }
    $button.parent().find("input").val(newVal);

    var valorTotal = 0;
    var valoresMultiplicar = 0;
    $(".qtdpedidos").each(function() {
      valorTotal += parseFloat($(this).data("preco") * $(this).val());
    })

    $(".item span").each(function() {
      valoresMultiplicar += parseFloat($(this).html());
    })

    if (valorTotal==0){
        $("#tot").text("");
        $("#resultado").text('');
    }else{
        $("#tot").text('R$'+(parseFloat(valorTotal+5).toFixed(2)));
        $("#resultado").text('R$'+parseFloat(valorTotal).toFixed(2));
    }




  });
});

When he appears on the button of "Finish" he should appear only what I solved on another page:

Page that should appear the data:

Order confirmation screen

inserir a descrição da imagem aqui

1 answer

0


Good morning,

You can use a session class, you yesterday the identifier of your product, and save in an array your complete object, right after, you send to a method that will record it in the session using session_start in php.

With jQuery you would have to assemble a file that received via post, then you would use ajax and send by post, but in this second case also using Sesssion not to lose what if it was included.

I will try to create an example as soon as I arrive at the computer and send you by this post.

  • Waiting for Marcus.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.