naveen
naveen

Reputation: 741

dynamic selection country city using javascript

I wrote the code for dynamic selection country city like this way.The code running fine on Mozila, Chrome, Opera, Safari and Internet Explorer 9, but the dynamic selection of country city code is not working on Internet Explorer 8 and earlier versions.

<form method=post id="formname" name="formname" action=eaccountdb.php 
      enctype="multipart/form-data"  onsubmit="return Validate();">
  <table class="style2">
    <tr>
      <td>
        <table align="left" width="100%">
          <tr>
            <td align="left">
              <label for="country">Country*</label>
      <?php
      $country = $_GET['country'];
      if ($country == null)
      {
          $data = mysql_query("select * from country where countryname !='$country'");
          echo "
                <select name='country' style='width:150px' id='country' 
                        onchange='show_country(this.value);'>
                  <option>Select Country</option>";
          while ($info = mysql_fetch_array($data))
          {
              echo "<option>". $info['countryname']."</option>" ;
          }
          echo "</select>";
      }
      ...

Upvotes: 1

Views: 601

Answers (1)

RobG
RobG

Reputation: 147403

At a guess, I would say it's because you aren't providing a value attribute for the option elements. In browsers conforming to W3C standards, the value of an option with no value attribute is the text of the option. Unfortunately IE 8 and lower didn't follow that particular part of the standard. The simple answer is to put a value in each option, something like:

  echo "<option value=". $info['cityname'].">". $info['cityname']."</option>" ; 

Upvotes: 1

Related Questions