Jump to content

Picker not behaving


zer0uk

Recommended Posts

Hello all,

Can anyone help me , the below code which creates a drop down list for a user works fine on a desktop but on a mobile seems to be random the course it selects 

 

Thanks in advance

 

<?php  
       // database connect
        include('../db_connect.php');

        // We need to use sessions, so you should always start sessions using the below code.
        session_start();
        // If the user is not logged in redirect to the login page...
        if (!isset($_SESSION['loggedin'])) {
	    header('Location: login.php');
	    exit();
        }
        // if submit button selected  run code
        if(isset($_POST['submit'])){
                $_SESSION['district'] = $_POST['district'];
                header('Location: add_d_choice.php');
            }   
?>
<!DOCTYPE html>
<html>

            <!-- Compiled and minified CSS -->
            <link rel="stylesheet" 
                href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">

                <!-- Compiled and minified JavaScript -->
                <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>

                <!--Import Google Icon Font-->
                <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
	

<header>       
<?php
include('../menu.php');
?>
</header>

<body bgcolor=#fafafa>
          

        
        <br>
        <br>



    <div class="container">
        <div class="row">
        <div class="card col s10 m8 l6 xl4 push-l3 push-m2 push-s1 push-xl4 z-depth-5">
        <div class="card-content">
            <div class="input-field col s12 m12 l12 xl12">
                    
                    
                    <form action="add_choice.php" method="POST">
                        <select name = "district">
                            <label>Select District you raced at</label>
                                    <option value="" disabled selected>Choose your district</option>
                                    <option value="Z">Zwift TT - Z</option>
                                    <option value="">--------------------</option>
                                    <option value="A">Central A</option>
                                    <option value="B">East - B</option>
                                    <option value="C">Lincolnshire - C</option>
                                    <option value="D">Liverpool - D</option>
                                    <option value="E">London East - E</option>
                                    <option value="F">London North - F</option>
                                    <option value="G">London South - G</option>
                                    <option value="H">London West - H</option>
                                    <option value="J">Manchester - J</option>
                                    <option value="K">Midland - K</option>
                                    <option value="L">North - L</option>
                                    <option value="M">North East - M</option>
                                    <option value="N">South East Midlands - N</option>
                                    <option value="O">North Midlands - O</option>
                                    <option value="P">South - P</option>
                                    <option value="Q">South East - Q</option>
                                    <option value="R">South Wales - R</option>
                                    <option value="S">South West - S</option>
                                    <option value="T">Teeside - T</option>
                                    <option value="U">West - U</option>
                                    <option value="V">Yorkshire - V</option>
                                    <option value="W">Scotland - W</option>
                                    <option value="Y">National - Y</option>
                        </select>
                                <input class="btn teal accent-4" type="submit" name="submit" value="Submit">
                                <br>
                                <br>
                    </form>
            </div>
        </div>
        </div>
        </div>
    </div>

</div>

 <!-- Javacript -->
 <script src=https://code.jquery.com/jquery-3.4.1.min.js></script>

<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>


<script>
        $(document).ready(function(){
            $('.sidenav').sidenav(); 
            $('select').formSelect();
            $('.datepicker').datepicker();
            $(".dropdown-trigger").dropdown();

 });

</script>

</body>
<footer>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<?php
include('../footer.php');
?>
</footer>

</html> 

 

Link to comment
Share on other sites

No it does not.  If the user clicks on a choice that is the value that should appear in your $_POST array as element 'district'  Of course - on many mobiles the screen is so small it would be easy to select the wrong one with my big fingers.

Link to comment
Share on other sites

Must be something in the hidden files that I can't see.  I took the basics of your script and ran this:

<?php
session_start();
// If the user is not logged in redirect to the login page...
// if submit button selected  run code
if(isset($_POST['submit']))
{
	$_SESSION['district'] = $_POST['district'];
	echo "You have selected ".$_POST['district'];
}
//  output the html now
?>
<!DOCTYPE html>
<html>
<body bgcolor=#fafafa>
<br>
<br>
<form action="test.php" method="POST">
<label>Select District you raced at</label>
<select name = "district">
<option value="" disabled selected>Choose your district</option>
<option value="Z">Zwift TT - Z</option>
<option value="">--------------------</option>
<option value="A">Central A</option>
<option value="B">East - B</option>
<option value="C">Lincolnshire - C</option>
<option value="D">Liverpool - D</option>
<option value="E">London East - E</option>
<option value="F">London North - F</option>
<option value="G">London South - G</option>
<option value="H">London West - H</option>
<option value="J">Manchester - J</option>
<option value="K">Midland - K</option>
<option value="L">North - L</option>
<option value="M">North East - M</option>
<option value="N">South East Midlands - N</option>
<option value="O">North Midlands - O</option>
<option value="P">South - P</option>
<option value="Q">South East - Q</option>
<option value="R">South Wales - R</option>
<option value="S">South West - S</option>
<option value="T">Teeside - T</option>
<option value="U">West - U</option>
<option value="V">Yorkshire - V</option>
<option value="W">Scotland - W</option>
<option value="Y">National - Y</option>
</select>
<br><br>
<input type="submit" name="submit" value="Submit">
<br>
<br>
</form>
<?php
exit();

This worked equally well on my pc and my iphone.  So - look for a problem in the JQ perhaps?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.