0
I’m trying to make a dynamic combobox with html, php and javascript.
To do this, I need to send the selected value in the first select (View) to my Controller file, but the following error occurs:
Notice: Undefined index: categid in C: xampp2 htdocs testes Catalog controller Account customerpartner addproduct.php
Could someone help me solve this mistake? Follow the codes.
JAVASCRIPT:
<script>
$(document).ready(function(){
$("select[name=product-category]").change(function(){
$("select[name=product-subcategory1]").html('<option value="">Carregando...</option>');
$.post("catalog/controller/account/customerpartner/addproduct.php",
{categid:$(this).val()},
function(valor){
$("select[name=product-subcategory1]").html(valor);
}
)
})
})
</script>
PHP
if ($_POST["categid"]) {
$categid = $_POST['categid'];
}
Thanks in advance for the help.
Recommended reading => I can use Empty and isset in a variable? and When should I use Empty or isset?
– rray
try to use
if (isset($_POST["categid"]))
– 13dev
I have tried using if (isset($_POST["categid"]){ echo $_POST["categid"]; }Else{ echo "fails"; } but fails anyway.
– João Vitor Dias