2012-05-18 32 views
1

我编写了像这样的动态选择国家城市的代码。在Mozila,Chrome,Opera,Safari和Internet Explorer上运行良好的代码,但国家城市代码的动态选择是不适用于Internet Explorer 及更早版本。动态选择使用javascript的国家城市

<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>"; 
     } 
     ... 
+1

请发布传递给浏览器的代码,而不是生成它的代码。 – RobG

回答

1

在猜测,我会说这是因为你没有提供value属性的选项元素。在符合W3C标准的浏览器中,没有值属性的选项的值是选项的文本。不幸的是,IE 8和更低版本并没有遵循该标准的特定部分。简单的答案是在每个选项中加入一个值,例如:

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