Jump to content

Recommended Posts

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.

Link to post
Share on other sites

<?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>

 

image.thumb.png.2abb92ac46b79a286583d732a0e6f9b7.png

 

How do I capture the selected value and post that value to another table.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.