HOME
DOMAIN
WEB HOST
AUTO Site
VPS SERVER
CLOUD HOST
SERVER
HK HOST
AGENT
SERVICE
html代码如下:
<select id="teId" name="te_id" onchange="getArea()"> <option value="1000">--请选择分类--</option> <option value="1">房产知识</option> <option value="8">房屋买卖</option> <option value="16">法律法规</option> <option value="24">银行贷款</option> <option value="31">房产类型</option> <option value="40">装修风水</option> <option value="47">房产经纪</option> <option value="52">其他问题</option> <option value="54">楼盘问答</option> </select> <span id="teTid" ></span> <span></span> <select id="wealth" name="wealth"> <option value="">--请选择悬赏积分--</option> <option value="0">我要给0</option> <option value="5">我要给5</option> <option value="15">我要给15</option> <option value="30">我要给30</option> <option value="50">我要给50</option> </select>
ajax代码如下:
// 创建ajax引擎 function getXmlHttpObject() { var xmlHttpRequest; if (window.ActiveXObject) { xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } else { xmlHttpRequest = new XMLHttpRequest(); } return xmlHttpRequest; } var myXmlHttpRequest = ""; function getArea(){ //alert(ID('teId').value); myXmlHttpRequest = getXmlHttpObject(); // 怎样判断是否可以www.111cn.net if (myXmlHttpRequest) { // post 发送数据 var url = "ajax_tiwen.php"; var date = "teId=" + ID('teId').value; myXmlHttpRequest.open("post", url, true); myXmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); myXmlHttpRequest.onreadystatechange = TiWen; myXmlHttpRequest.send(date); } }
php代码如下:
$str = ''; if(!$teamId) { $str .= '<select name="te_tid">'; $str .= ' <option value="1000">--请选择分类--</option>'; $str .= '</select>'; echo $str; exit; } else { $str .= '<select id="teTid" name="te_tid">'; $str .= ' <option value="1000">--请选择分类--</option>'; foreach($teamId as $v) { $str .= '<option value="'.$v['id'].'">'.$v['tname'].'</option>'; } $str .= '</select>'; echo $str; }