TheFearful 0 Newbie Poster

Hey everyone, I am trying to be able to have a textbox that only accepts numbers that is either 1 or greater but less than the number of items in a table from the databse. The queries work fine and such. What I'm trying to figure out is how to get the value from the user input without having to submit the values. The goal is to have a drop down menu (multiple ones depending on the user's input) appear where the user can pick the numbers from the table in the order that they want. Is that possible? This is what I have so far:

<?php
        include_once("sqlConnect.php");

        $stmt = mysqli_stmt_init($conn);
        if(mysqli_stmt_prepare($stmt, "SELECT COUNT(*) FROM CheckListItems"))
        {
                mysqli_stmt_bind_param($stmt, 'i');
                mysqli_stmt_execute($stmt);
                mysqli_stmt_bind_result($stmt, $count);
                mysqli_stmt_fetch($stmt);
        }

        if(mysqli_stmt_prepare($stmt, "SELECT CheckListID, Description FROM CheckListItems"))
        {
                mysqli_stmt_bind_param($stmt, 'is');
                mysqli_stmt_execute($stmt);
                mysqli_stmt_bind_result($stmt, $CheckListID, $Description);
        }

?>

<html>
        <head>
                <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"> </script>
                <script>
                        $(document).ready(function()
                        {
                                $("#numOfSteps").keyup(function()
                                {
                                        var value = $(this).val();
                                        alert(value);
                                }).keyup();
                        });
                </script>
        </head>

        <body>
                <table>
                <?php
                        echo "<h3>This is the key</h3>";
                        while(mysqli_stmt_fetch($stmt))
                        {
                                echo "<tr>";
                                echo "<td> $CheckListID</td>";
                                echo "<td>$Description</td>";
                                echo "</tr>";
                        mysqli_stmt_close($stmt);
                        mysqli_close($conn);

                ?>

                </table>
                <br>How many steps do you want for this ticket type?
                <br>Pick a number between 1 and <?php echo $count; ?>
                <form method="GET">
                        <input type="number" id="numOfSteps" name="numOfSteps" value="1" min="1" max="<?php echo $count; ?>" />
                        <button type="button" id="numOfStepsButton">Submit</button>
                <!--    <select name="steps" id="steps-select"> -->
                        <?php
                                echo $_GET['numOfSteps']."<br>";
                                for($j=1; $j <= $_GET['numOfSteps']; $j++)
                                {
                                        echo "<select>";
                                        for($i = 1; $i <= $count; $i++)
                                        {
                                                echo "<option value='$i'>$i</option>";
                                        }
                                        echo "</select>";
                                }
                        ?>
                        <p></p>
                </form>
        </body>

</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.