<?php$query="select * from test where 1";$query1=mysql_query($query) or die(mysql_error());if(mysql_num_rows($query1) > 0){$row = mysql_fetch_row($query1);@mysql_free_result($query1);?><html><script>function areas_change(th){ //alert(document.getElementById('areas_str').value); if(2==th){ //alert(document.getElementById('city').value); document.getElementById('area').value=document.getElementById('city').value; } else if(1==th) document.getElementById('area').value=document.getElementById('pro').value; else document.getElementById('area').value=document.getElementById('county').value; }</script><body><select name="areas" id="areas" onchange=" areas_change(this.value);"><option value="3" selected="selected">请选择</option> <option value="<?php echo $row[0];?>">县级</option> <option value="2">市级</option> <option value="1">省级</option></select><input type="hidden" readonly name="city" id="city" value='123'> <input type="hidden" name="pro" id="pro" value='123'> <input type="hidden" name="county" id="county" value='213'><input type="text" maxlength='18' name="area" id="area" value='132' onafterpaste="this.value=this.value.replace(/\'/g,'')"></body></html>如何获得下拉列表的值,只需要$_POST['areas']; 这个例子是php和html代码混合的例子,是事先提取数据库的值放到select的value中,然后change后用于post提交。当然你可以用ajax进行异步调用
<select name="aitem" id="aitem"> <option value="请选择" selected>请选择</option> <option value="小贴士" >小贴士</option> <option value="房间贴士" >房间贴士</option> <option value="咨询信息" >咨询信息</option> </select>利用表单提交 只在提取$aitem=$_POST[aitem];