动态下拉菜单POST

时间:2013-09-27 19:58:24

标签: javascript php html ajax

我正在尝试发布从每个下拉菜单中获得的值,这是一个n级,但是我将最多使用它们3.我如何发布每个选择的每个值?

 <?php

  include('dbcon.php');

  if($_REQUEST)
   {
$id     = $_REQUEST['parent_id'];

$query  = "select * from ajax_categories where pid = ".$id;
$results  = @mysql_query( $query);
$num_rows = @mysql_num_rows($results);
if($num_rows > 0)
{?>
    <select name="sub_category" class="parent">
    <option value="" selected="selected">-- Sub Category --</option>
    <?php
    while ($rows = mysql_fetch_assoc(@$results))
    {?>
        <option value="<?php echo $rows['id'];?>"><?php echo $rows['category'];?></option>
    <?php
    }?>
    </select>   
<?php   
}
else{echo '<label style="padding:7px;float:left; font-size:12px;">No Record Found !</label>';}
  }

  ?>

http://www.99points.info/2010/12/n-level-dynamic-loading-of-dropdowns-using-ajax-and-php/

1 个答案:

答案 0 :(得分:0)

更改您喜欢的选项

<select name="sub_category" class="parent">
    <option value="" selected="selected">-- Sub Category --</option>
 while ($rows = mysql_fetch_assoc(@$results))
    {?>
      echo   '<option value="'.$row['id'].'">'.$rows['category'].'</option>';

    <?php
    }?>
    </select>   
<?php   
}
else{echo '<label style="padding:7px;float:left; font-size:12px;">No Record Found !</label>';}
  }
 </select>