force option from – Sergei Beregov Feb 19 '14 at 18:43

  • 1
    Or use: else { $("form").submit(); } – Sergei Beregov Feb 19 '14 at 18:46
  • 0
    <label>Select Tank:</label><br />
    <select class="text" id="seltank" name="tank">
        <option value="All" selected="selected"> Select Tank </option>
    </select>
    

    in the client side click event of your submit button add some javascript to check the value of your drop down.

    if(document.getElementById("seltank").value == "All")
    {
         //put some code to alert the user or show error
        return false; //this should prevent your post
    }
    

    Similar post is here How do I cancel form submission in submit button onclick event?

    Community
    • 1
    • 1
    kale909
    • 129
    • 1
    • 4
    0

    Here's what I do:

    <select class="text2" name="tank" id="mySelect">
         <option></option>
         <option value="4"> Tank#1 </option>
         <option value="9"> Tank#2 </option>
         <option value="21"> Tank#3 </option>
         <option value="34"> Tank#4 </option>
    </select>
    

    If the user hits submit without making a selection, they will be prompted to select an option automatically. The limitation is that you don't get a pretty little "select an option" placeholder.

    Jacob McKay
    • 2,776
    • 1
    • 19
    • 20
    0

    Maybe this can help. Im yet to find a stable answer

    If using php:

    $val = $_POST['select_input'];  <--- works fine
    

    or $val = $request->select_input <---- can be problematic

    On Html

    <select id="select_input" name="select_input" >                                                                                           
        <option value="0">Pending</option>                                                                                                                                                                                    
        <option value="1">Approved</option>                                                                                                                                                                                                                                                                                                                                                                                  
        <option value="0" selected>Pending</option>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
    </select>