Jump to content

hiding a value


skyhighweb
 Share

Recommended Posts

Then use delimiter to separate values and send as array of values, then use explode to separate those values by delimiter, and show the value required using index ref

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        $teamRec = "";
        $team_array = [];
        $team_array['Team1'] = ['Team #1 dropdown1', 'Team #1 dropdown2', 'Team #1 dropdown3', 'Team #1 dropdown4'];
        $team_array['Team2'] = ['Team #2 dropdown1', 'Team #2 dropdown2', 'Team #2 dropdown3', 'Team #2 dropdown4'];
        ?>

        <form id="myform" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
            <select name="willwin" class="form-control" onchange="dothis()">
                <option value="">Select Team </option>
                <?php
                $optioncount = 0;
                foreach ($team_array as $key => $value) {
                    $optioncount++;
                    if ($key === $teamRec) {
                        echo '<option class="team' . $optioncount . '" value="' . $key . ', Team #' . $optioncount . '" selected="selected">Team #' . $optioncount . '</option>';
                    } else {
                        echo '<option class="team' . $optioncount . '" value="' . $key . ', Team #' . $optioncount . '">Team #' . $optioncount . '</option>';
                    }
                }
                ?>



            </select><br>
            <?php
            if (isset($_POST['willwin'])) {
                $teamRec = explode(',', $_POST['willwin']);

                echo '1st $_POST["willwin"] value of Response: ' . $teamRec[0] . '<br>';
                echo '2nd $_POST["willwin"] value of Response: ' . $teamRec[1] . '<br>';
            }
            ?>


            <input type="submit">
        </form>

        <script>
            function dothis() {
                x = document.getElementById('myform').submit();

            }


        </script>

    </body>
</html>

 

Link to comment
Share on other sites

1 hour ago, dsonesuk said:

Then use delimiter to separate values and send as array of values, then use explode to separate those values by delimiter, and show the value required using index ref


<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        $teamRec = "";
        $team_array = [];
        $team_array['Team1'] = ['Team #1 dropdown1', 'Team #1 dropdown2', 'Team #1 dropdown3', 'Team #1 dropdown4'];
        $team_array['Team2'] = ['Team #2 dropdown1', 'Team #2 dropdown2', 'Team #2 dropdown3', 'Team #2 dropdown4'];
        ?>

        <form id="myform" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
            <select name="willwin" class="form-control" onchange="dothis()">
                <option value="">Select Team </option>
                <?php
                $optioncount = 0;
                foreach ($team_array as $key => $value) {
                    $optioncount++;
                    if ($key === $teamRec) {
                        echo '<option class="team' . $optioncount . '" value="' . $key . ', Team #' . $optioncount . '" selected="selected">Team #' . $optioncount . '</option>';
                    } else {
                        echo '<option class="team' . $optioncount . '" value="' . $key . ', Team #' . $optioncount . '">Team #' . $optioncount . '</option>';
                    }
                }
                ?>



            </select><br>
            <?php
            if (isset($_POST['willwin'])) {
                $teamRec = explode(',', $_POST['willwin']);

                echo '1st $_POST["willwin"] value of Response: ' . $teamRec[0] . '<br>';
                echo '2nd $_POST["willwin"] value of Response: ' . $teamRec[1] . '<br>';
            }
            ?>


            <input type="submit">
        </form>

        <script>
            function dothis() {
                x = document.getElementById('myform').submit();

            }


        </script>

    </body>
</html>

 

so this is like an example i believe right

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...