xtekuta Posted November 21, 2019 Share Posted November 21, 2019 I have this ajax function in my PRS.php that whenever i select a value from dropdown, a text field will show an output based on the value which selected. In my console i see there was a POST everytime theres a select value from the drop down. But im getting an error 'Undefined Variable' in ff.php which fetching the POST value from PRS.php Im new in jQuery so im stuck here in this problem. Any solution for this ? Thanks in advance. Here is my code in PRS.php <?php $drp = mysqli_query($conn,"SELECT productcode FROM products"); ?> <td><select name="drpcode" onchange="getState(this.value)" class="form-control name_list"><?php while ($dp = mysqli_fetch_array($drp)) { ?> <option value="<?php echo $dp['productid']; ?>"><?php echo $dp['productcode']; ?></option><?php } ?></select></td> <td><input type="text" id="brandss" name="brand" placeholder="Brand" class="form-control name_list" required value=" "></td> My code in ff.php <?php require_once("conn.php"); $id = $_POST['productid']; $query = mysqli_query($conn,"SELECT productbrand FROM products WHERE productid = '$id' "); while($rs = mysqli_fetch_array($query,MYSQLI_BOTH)) { $brand = $rs['productbrand']; } echo $brand; ?> Quote Link to comment Share on other sites More sharing options...
requinix Posted November 21, 2019 Share Posted November 21, 2019 Undefined variable? Which variable? Is it $brand? Quote Link to comment Share on other sites More sharing options...
Barand Posted November 21, 2019 Share Posted November 21, 2019 It's hard to find something that is defined. Your first query selects productcode from products but the value for the options is "productid" The select is named "drpcode" yet you are expecting $_POST[''productid'] 4 hours ago, xtekuta said: Im new in jQuery What jQuery? What AJAX function? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.