The first thing is that I created a select button using javascript, here is the code in :
var select = "<form action='' method='post'><select id='line' name='choice'>";
for (var j = 0; j < jsondata.length; j++) {
select += '<option>' + jsondata[j]['productLine'] + '</option>'
};
select += "</select></form>";
document.getElementById("select").innerHTML = select; // put the button in html tag
Now I'm trying to get the value of the selected content each time, and then pass the value to the SQL in PHP, here are lines of codes of PHP
$p = $_POST['choice'];
echo $p;
$sql_p = "SELECT productCode,productName
FROM products
WHERE productLine = '".$p."'";
But I got the Undefined index: choice. And no value is received.
Could anyone help me with this?