Passing variable value by $ .post

0

I'm trying but I do not know how to send the value of select to page pagseguro.php

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pedido de teste</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script></head><body><div><h1>ProdutodeTeste</h1><p>Valor:299,00</p><buttononclick="enviaPagseguro();">Comprar</button><br />
    <img src="loading.gif" id="loading" style="visibility: hidden">
</div>

<form id="comprar" action="https://pagseguro.uol.com.br/v2/checkout/payment.html" method="post" onsubmit="PagSeguroLightbox(this); return false;">
    <input type="hidden" name="code" id="code" value="" />
    <select name="itemAmount1">
        <option value="10.00">Tentar obter 1000 Donate Points</option>
        <option value="30.00">Tentar obter 3500 Donate Points</option>
        <option value="50.00">Tentar obter 6000 Donate Points</option>
        <option value="80.00">Tentar obter 9500 Donate Points</option>
        <option value="150.00">Tentar obter 20000 Donate Points</option>
        <option value="225.00">Tentar obter 30000 Donate Points</option>
    </select>

</form>

<script type="text/javascript" src="https://stc.pagseguro.uol.com.br/pagseguro/api/v2/checkout/pagseguro.lightbox.js"></script><script>functionenviaPagseguro(codigo){$.post('salvarpedido.php','',function(idPedido){$('#loading').css("visibility","visible");

            $.post('pagseguro.php',{idPedido: idPedido},function(data){

                $('#code').val(data);
                $('#comprar').submit();

                $('#loading').css("visibility","hidden");
            })
        })
    }
</script>

</body>
</html>

Someone?

    
asked by anonymous 17.11.2017 / 04:41

2 answers

1

You can get the value of select with the code:

$("select[name='itemAmount1']").val();
    
17.11.2017 / 04:52
0

Your code is right, just add the post variable in itemAmount1.

On the pagseguro.php page:

$data['itemAmount1'] = $_POST['itemAmount1'];

The name of the post parameter should be the same as the name of the select.

    
17.11.2017 / 04:59