【发布时间】:2015-01-04 02:39:17
【问题描述】:
我有一个如下所示的表格:
<?php
$list_id = $db_connect->get_results($db_connect->prepare('SELECT * FROM users WHERE wp_ID= %d AND svr_region=%d', $wpid, 1));
?>
<form name = "reset_data" action="<?php the_permalink(); ?>" method="post">
<select id = "select_id" name="select_id" required>
<option value="" > - Chose ID - </option>
<?php
foreach ($list_id as $list_id) {
$get_list_id = $list_id->ID;
$get_list_name = $list_id->name;
echo '<option value="' . $get_list_id . '" >[' . $get_list_id . '] ' . $get_list_name . '</option>';
}
?>
</select>
<select id = "select_role" name="select_role" >
<option value="" > - Chose Role - </option>
<?php
$get_role = GetRoleList($_POST['select_id']);
echo $get_role;
?>
</select>
<input type="submit" value="Get Data! »"/>
</form>
如果#select_id 有一个空值,我如何创建一个JQuery 来禁用#select_role。
#select_id的值类型为Integer,选择#select_id后会执行一个PHP函数GetRoleList ( $_POST['select_id'] ),返回结果如下'<option value="' . $nick_str . '" >' .$nick_str. '</option>'
【问题讨论】: