Hi, how are you all concerned about a select? It happens that I want one of the values of them example:
<select id="test">
<option value="100" selected>Precio1</option>
<option value="200" selected>Precio2</option>
</select>
It happens that this is a list to send the data in a form of paypal and I have the following
$pp = array(
'cmd' => '_xclick',
'cert_id' => $cert_id,
'business' => '[email protected]',
'receiver_email' => '[email protected]',
'custom' => '1',
'item_name' => **>>Justo acá quiero que me aparezca el "value" osea en la option 1 que me salga 100 <<** ,
'currency_code' => 'USD',
'amount' => '1',
.....................
);
Well I was trying with javascript with an onclick in the form and adding a post in item_name example $ _POST ['test'],
while the javascript code I tried was this
function mostrarValue(){
var selObj = document.getElementById('test');
var selIndex = selObj.options[selObj.selectedIndex].value;
}
I hope and someone can guide me in this I would be very grateful, greetings and thanks in advance.
This is the code itself I'm using.
<script language="javascript">
function mostrarValue(){
var selObj = document.getElementById('test');
var selIndex = selObj.options[selObj.selectedIndex].value;
}
</script>
<p>Seleccione uno de los articulos</p>
<label class="youplay-select">
<select id="test" name="test">
<option value="" selected>Seleccionar</option>
<option value="1000">Articulo1</option>
<option value="1001">Articulo2</option>
<option value="1002">Articulo3</option>
</select>
</label>
<?php
$cert_id = 'CERTIFICADOPAYPAL';
include("Class.PayPalEWP.php");
$paypal = new PayPalEWP();
$paypal->setTempFileDirectory("tmp");
$paypal->setCertificate("my-pubcert.pem", "my-prvkey.pem");
$paypal->setPayPalCertificate("paypal_cert_pem.txt");
$paypal->setCertificateID($cert_id);
$pp = array(
'cmd' => '_xclick',
'cert_id' => $cert_id,
'business' => '[email protected]',
'receiver_email' => '[email protected]',
'custom' => '1',
'item_name' $_POST['test'],
'currency_code' => 'USD',
'amount' => '1',
'lc' => 'ES',
'no_note' => '1',
'no_shipping' => '1',
//'return' => '',
'cancel_return' => '',
//'notify_url' => '',
'cbt' => 'Volver al sitio web',
);
?>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" id="pay_pal_form" method="POST" name= "form1" onclick="mostrarValue();">
<input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----<?php echo $paypal->encryptButton($pp); ?>-----END PKCS7-----"/>
<input type="image" src="https://www.paypal.com/es_XC/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal, la forma más segura y rápida de pagar en línea.">
<img alt="" border="0" src="https://www.paypal.com/es_XC/i/scr/pixel.gif" width="1" height="1"></p></div>
</form>
I want this to send me the value of the "item_name" so in the ipn insert it in a db, but in the ways I've tried it saves what is "Price1" and not "100" and with the method that I highlight in my code when sending the form asks me to enter a new name, it takes as if it did not have any item_name