addonisdl addonisdl - 6 months ago 14
PHP Question

Open Popup with post data

I got a javascript for send value to a Popup but only works with

$_GET['value']
because when a change to
$_POST['value']
it shows this message

Notice: Undefined index: value in C:\wamp\www\corti\presupuestos\precio.php on line 10


this is the javascript code

function envia(){
var co = $("#codart").val();
var pag = 'precio.php?value='+co;
window.open(pag,'Popwin','height=400, width=400');
}


this is the button

<img src="../png/buscar.png" height="16" width="16" onClick="javascript: envia();">


and this is de popup php file

<?php
$c=$_POST['value'];
echo $c;
?>


thanks for you help and your time

Answer

this is because $_POST can't read url strings query. and you are sending your variable in url string query. that's why you have to use $_GET in your case.

Otherwise, you need to use ajax such as mentioned in many websites articles to perform post. and here's one for example:

http://www.javascriptkit.com/dhtmltutors/ajaxgetpost.shtml

Comments