girish1 Posted April 26, 2021 Share Posted April 26, 2021 I am a beginner. How do you capture the selected value in dynamic dropdown and submit it to a different table in mysql Quote Link to comment https://forums.phpfreaks.com/topic/312546-dynamic-drop-down/ Share on other sites More sharing options...
maxxd Posted April 27, 2021 Share Posted April 27, 2021 You'll need to look into AJAX. Basically, using JavaScript you trigger a call (ajax or fetch) to a php script on your server - in the call you pass the selected value. The php script will use this passed value to determine what to show in the next drop-down and return that to the JavaScript which will then display that data to the user as a second drop-down. Quote Link to comment https://forums.phpfreaks.com/topic/312546-dynamic-drop-down/#findComment-1586170 Share on other sites More sharing options...
girish1 Posted April 27, 2021 Author Share Posted April 27, 2021 sorry, i should have been more specific. script language is php. this is not about dependent dropdowns. will send you images and code. thank you. Quote Link to comment https://forums.phpfreaks.com/topic/312546-dynamic-drop-down/#findComment-1586172 Share on other sites More sharing options...
girish1 Posted April 27, 2021 Author Share Posted April 27, 2021 <?php include_once "configdb.php"; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <select name="category" id="category"> <option value="">Select Category</option> <?php $query = "SELECT * FROM category"; $result = $conn->query($query); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo "<option value='{$row["cat_id"]}'>{$row['cat_name']}</option>"; } }else{ echo "<option value=''>Category not available</option>"; } ?> </select><br><br> </body> </html> How do I capture the selected value and post that value to another table. Quote Link to comment https://forums.phpfreaks.com/topic/312546-dynamic-drop-down/#findComment-1586173 Share on other sites More sharing options...
Barand Posted April 27, 2021 Share Posted April 27, 2021 See https://www.php.net/manual/en/language.variables.external.php Quote Link to comment https://forums.phpfreaks.com/topic/312546-dynamic-drop-down/#findComment-1586177 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.