Multiple Java Script In One Page Error November 07, 2022 Post a Comment I have this code that is working originally: Please Select Solution 1: As suggested in Comments, you made mistakes in your code; 1.Binding change function with wrong selector id $("#Name2").change(function(){ Copy and the HTML is <select name="Name" required class="form-control" id="Name"> Copy Should be $("#Name").change(function(){ it will fix the problem Undefined selname at line 5 2.Name Ajax Method success function success: function(data) { $("#Schedule2").html(dataname); } Copy Should be $("#Schedule2").html(data); And in PHP; credit goes to @j08691 change $selDate $selDate = $_POST['selname']; Copy to $selname $selname = $_POST['selname']; $sql="SELECT * FROM clinic.appoint WHERE name='$selname'"; Copy As you said in question, your first Ajax Call is working fine and you are facing problem in 2nd Ajax call method, after fixing above mistakes HTML <th> <select name="Name" required class="form-control" id="Name"> <option value="">Please Select Name</option> <?php $sql3="SELECT * FROM clinic.appoint GROUP BY name"; $result3 = mysqli_query($con, $sql3) or die($sql3."<br/><br/>".mysql_error()); while($rows3=mysqli_fetch_array($result3)){?> <option value="<?php echo $rows3['name'] ?>"><?php echo $rows3['name'] ?></option> <?php } ?> </select> </th> Copy AJAX $(document).ready(function(){ $("#Name").change(function(){ var selname =$(this).val(); display_name(selname); }); // This is the function... function display_name(selname) { $("#scheduleName").html(selname); var dataString = 'selname='+ selname; $.ajax({ type: "POST", url: "getdatabyname.php", data: dataString, cache: false, success: function(data) { $("#Schedule").html(data); } }); } }); Copy PHP <?php require_once ('../include/global.php'); if($_POST['selname']) { $selname = $_POST['selname']; $sql="SELECT * FROM clinic.appoint WHERE name='$selname'"; $result = mysqli_query($con, $sql) or die($sql."<br/><br/>".mysql_error()); while($rows=mysqli_fetch_array($result)){ ?> <tr> <td scope="row"><?php echo $rows['time'] ?></td> <td scope="row"><?php echo $rows['name'] ?></td> <td scope="row"><?php echo $rows['date'] ?></td> <td scope="row"><form action='/clinic form/appoint/delete.php'=<?php echo $rows['id']; ?>' method="post"> <input type="hidden" name="id" value="<?php echo $rows['id']; ?>"> <input type="submit" name="submit1" value="Done"> </form> </td> </tr> <?php } } ?> Copy (OP reached me via email and explained what he is trying to do) Now, you are fetching result by 2 different <select> element using Ajax and trying to show the result based on <select> element and in both Ajax calls success: function you are targeting 2 different id's to show the data for each <select> Ajax call e.g //For Date Result $("#Schedule").html(data); //For Name Result $("#Schedule2").html(data); Copy I would suggest to use the same id selector in both Ajax calls success: function to show the data $("#Schedule").html(data); Copy By doing so, when you switch between select element, to show the data, it will replace the first fetched data. Last, I totally agree with @Jared Smith what he said about mixing PHP and JavaScript, it's really not good practice. Share Post a Comment for "Multiple Java Script In One Page Error" Top Question Secure Way Of Passing Values Using Post Method I need to pass a few values using POST method form to anoth… Border Issue In Floating Div Further to the discussion in Floating div issue in IE i add… Red Border Still Appears On Inputs After Resetting An Html 5 Form Firefox I have an HTML 5 form! Great, I'm excited! I decide to … Tooltip(title Attribute) Is Getting Truncated Scenario: I am working on a product where i need to display… How To Hide And Show A Table-row (css-tables) I'm trying to hide and show a table row using css-table… SVG Animation And Firefox I'm struggle with SVG animation drawing, which is work … Dropdown Menu On Refresh Changes Javascript I have implemented a navbar uisng bootstrap 4,in which I ha… Flex-box Only Display As Many Items That Fit In A Container I want to only use CSS to make it so I have a container whi… How To Prevent Div From Getting Cut Of When Resizing Window? I have a div on the left side of the browser that shows fin… Html5 Multiple Canvases Event Listener - How To Determine Which Canvas Experienced The Event? I'm new to JS. I'm not using jQuery, and I have a q… December 2024 (1) November 2024 (39) October 2024 (56) September 2024 (18) August 2024 (192) July 2024 (178) June 2024 (395) May 2024 (700) April 2024 (462) March 2024 (878) February 2024 (949) January 2024 (810) December 2023 (851) November 2023 (425) October 2023 (657) September 2023 (299) August 2023 (328) July 2023 (278) June 2023 (340) May 2023 (206) April 2023 (151) March 2023 (138) February 2023 (178) January 2023 (241) December 2022 (132) November 2022 (226) October 2022 (179) September 2022 (158) August 2022 (296) July 2022 (90) Menu Halaman Statis Beranda © 2022 - Html5 Developer