Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8015757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:20:30+00:00 2026-06-04T20:20:30+00:00

My problem is option value which is <option selected=selected disabled=disabled>Select a city…</option> The problem

  • 0

My problem is option value which is
<option selected="selected" disabled="disabled">Select a city...</option>
The problem is : despite this option having no value, php code sees its value as * ‘Select a city’*. So, my code if(isset($_POST['city']) returns always true even a city is not choosed. How can I solve this?

Here is html code :

<form id="city_form">

  <select id="city" name="city">
    <option selected="selected" disabled="disabled">Select a city...</option>
    <option value=1 name="city1">City 1</option>
    <option value=2 name="city2">City 2</option>
    <option value=3 name="city3">City 3</option>
    <option value=4 name="city4">City 4</option>
  </select>

  <input type="submit" value="Submit form" id="submit_button" />

</form>
<div id="show_city"></div>

Here is jquery codes :

$('#submit_button').click(function(e) {
  e.preventDefault();
  var data = $('#city_form').serialize();
  $.post(
         "fetch_city.php",
          data,
          function (response) {
             $('#show_city').html(response);
          }
        );
});

Here is fetch_city.php :

if (isset($_POST['city']) && !empty($_POST['city'])) {

  $city_id = $_POST['city']);
  echo $city_id;

} else {
  echo "You did not select a city...!";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:20:31+00:00Added an answer on June 4, 2026 at 8:20 pm

    You can’t. Give it a meaningful sentinel value and ignore the control if that value comes up.

    <option selected="selected" disabled="disabled" value="">Select a city...</option>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having a problem with dynamically populated select boxes using jQuery. Basically, my code calls
ok so i have some select tags of cities <select onchange=storeCity(this.value, false) name=search[city] id=search_city
I'm having a bit problem with reading argument value in haskell: I'm having options
Example of the problem If I have a list of valid option strings which
I have select option in my page or drop down list,my problem is how
I previous recieved help with a problem, getting a multiple option select form to
I am trying to change the selected option in a select dropdown box with
So I have this problem, which I don't see how it's happening. Basically I
$('#sellist option').each(function(index) { var str ='4/5/8'; var substr = str.split('/'); if (substr[0] == $(this).attr('value'))
I have a select, for which a onchange event is set. The problem is,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.