急````帮帮忙````联动菜单的增删改查不知道怎么实现 http://www.dwww.cn/News/2007-9/200793165615507.shtml 看一看 或许有帮助 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 已经帮你修改到可以获取到值了..剩下的就自己做把..数据库名改回你自己的数据库名..文件内容如下:index.php<?php if($_GET['act']=='insert') { echo "one-value:".$_POST['province_one']."<br>"; echo "two-value:".$_POST['province_two']."<br>"; echo "three-value".$_POST['province_three']."<br>"; }?><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script type="text/javascript">var xmlHttp;var requestType="";function createXMLHttpRequest(){ if(window.ActiveXObject) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest) { xmlHttp=new XMLHttpRequest(); }}function queryCity(citycode){ createXMLHttpRequest(); type="city"; var url="data.php?provincecode="+citycode; xmlHttp.open("GET",url,true); xmlHttp.onreadystatechange=handleStateChange; xmlHttp.send(null);}function queryArea(citycode){ createXMLHttpRequest(); type="area"; var url="data.php?citycode="+citycode; xmlHttp.open("GET",url,true); xmlHttp.onreadystatechange=handleStateChange; xmlHttp.send(null);}function handleStateChange(){ if(xmlHttp.readystate==4){ if(xmlHttp.status==200){ if(type=="city"){ showcity(); }else if(type="area"){ showarea(); } } }}function showcity(){ document.getElementById("city").innerHTML=xmlHttp.responseText; document.getElementById("area").innerHTML="";}function showarea(){ document.getElementById("area").innerHTML=xmlHttp.responseText;}</script></head><body><?php $conn=mysql_connect("localhost","root","2260375"); mysql_select_db("novel"); mysql_query("set names 'utf8'"); $sql="select * from province"; $result=mysql_query($sql); echo "<form name='form1' action='?act=insert' method='post'>\n"; echo "<select id='province' name='province_one' onchange='queryCity(this.options[this.selectedIndex].value)'>\n"; echo "<option value='-1' selected>请?择省份</option>\n"; while($row=mysql_fetch_row($result)){ echo "<option value='$row[1]'>$row[2]</option>\n"; } echo "</select>\n"; echo "<span id='city'></span>\n"; echo "<span id='area'></span>\n"; echo "<input type='submit'>"; echo "</form>\n";?></body></html>Data.php<? $conn=mysql_connect("localhost","root","2260375"); mysql_select_db("novel"); mysql_query("set names 'utf8'"); if($provincecode!=""&&$provincecode!=650000&&$provincecode!=710000&&$provincecode!=810000&&$provincecode!=820000&&$provincecode!=110000&&$provincecode!=120000&&$provincecode!=310000&&$provincecode!=500000){ $sql="select * from city where provincecode=$provincecode"; $result=mysql_query($sql); echo "<select onchange='queryArea(this.options[this.selectedIndex].value)' name='province_two'>\n"; echo "<option value='-1' selected>ffsdfsf</option>\n"; while($row=mysql_fetch_row($result)){ echo "<option value='$row[1]'>$row[2]</option>\n"; } echo "</select>\n"; } if($citycode!=""){ $sql="select * from area where citycode=$citycode"; $result=mysql_query($sql); echo "<select name='province_three'>\n"; echo "<option value='-1' selected>fsdfsfs</option>\n"; while($row=mysql_fetch_row($result)){ echo "<option value='$row[1]'>$row[2]</option>\n"; } echo "</select>\n"; }?> 我的意思是````比如现在选择的是:福建省-福州-长乐将数据存入数据库里面了是没问题的```如果要改变现在已选的值,就要获取显示原来已选的:福建省-福州-长乐再进行更改但我无法将已选值,附值到菜单中,麻烦 dada20042030 再帮帮忙```谢谢 不知道这个符合你的要求不。。try againindex.php<?php if($_GET['act']=='insert') { echo "one-value:".$_POST['province']."<br>"; echo "two-value:".$_POST['city']."<br>"; echo "three-value".$_POST['area']."<br>"; }?><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script type="text/javascript">var xmlHttp;var requestType="";function createXMLHttpRequest(){ if(window.ActiveXObject) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest) { xmlHttp=new XMLHttpRequest(); }}function queryCity(citycode){ createXMLHttpRequest(); type="city"; var url="data.php?provincecode="+citycode; xmlHttp.open("GET",url,true); xmlHttp.onreadystatechange=handleStateChange; xmlHttp.send(null);}function queryArea(citycode){ createXMLHttpRequest(); type="area"; var url="data.php?citycode="+citycode; xmlHttp.open("GET",url,true); xmlHttp.onreadystatechange=handleStateChange; xmlHttp.send(null);}function handleStateChange(){ if(xmlHttp.readystate==4){ if(xmlHttp.status==200){ if(type=="city"){ showcity(); }else if(type="area"){ showarea(); } } }}function showcity(){ var return_value=xmlHttp.responseText.split('|'); document.getElementById("city").length=0; for(var i=0;i<return_value.length;i++) { new_option=return_value[i].split(','); option_text=new_option[0]; option_value=new_option[1]; document.getElementById("city").options.add(new Option(option_value,option_text)); } }function showarea(){ document.getElementById("area").length=0; var return_value=xmlHttp.responseText.split('|'); for(var i=0;i<return_value.length;i++) { new_option=return_value[i].split(','); option_text=new_option[0]; option_value=new_option[1]; document.getElementById("area").options.add(new Option(option_value,option_text)); }}function get_value(action){ /* 获取到数据以后就用ajax去插入和更新。要不然表单提交以后就会刷新的了。 */ var provinces=document.form1.province.value; var citys=document.form1.city.value; var areas=document.form1.area.value; alert("进行的动作是:"+action); alert("省ID:"+provinces); alert("市ID:"+citys); alert("区域ID:"+areas); }</script></head><body><?php $conn=mysql_connect("localhost","root","2260375"); mysql_select_db("novel"); mysql_query("set names 'utf8'"); $sql="select * from province"; $result=mysql_query($sql);?><form action="?act=insert" method="POST" name="form1" onsubmit="set_value();"> <select onchange='queryCity(this.options[this.selectedIndex].value)' id='province' name="province"><?php while($row=mysql_fetch_row($result)){ echo "<option value='$row[1]'>$row[2]</option>\n"; } ?> </select> <select id="city" onchange='queryArea(this.options[this.selectedIndex].value)' name="city"></select> <select id="area" name="area"></select> <input type="button" onclick="get_value('insert')" value="insert"> <input type="button" onclick="get_value('update')" value="update"></form></body></html>data.php<? $conn=mysql_connect("localhost","root","2260375"); mysql_select_db("novel"); mysql_query("set names 'utf8'"); if($provincecode!=""&&$provincecode!=650000&&$provincecode!=710000&&$provincecode!=810000&&$provincecode!=820000&&$provincecode!=110000&&$provincecode!=120000&&$provincecode!=310000&&$provincecode!=500000){ $sql="select * from city where provincecode=$provincecode"; $result=mysql_query($sql); while($row=mysql_fetch_row($result)){ $str.=$row[1].",".$row[2]."|"; } echo $str; } if($citycode!=""){ $sql="select * from area where citycode=$citycode"; $result=mysql_query($sql); while($row=mysql_fetch_row($result)){ $str.=$row[1].",".$row[2]."|"; } echo $str; }?> 这不是我想要的`麻烦 dada20042030 再帮忙看看,下面有下例子,我在那里面说的很清楚,http://www.51chinajz.com/test/index.html希望能抽点时间再帮小弟看看.只要能帮忙实现这个功能``三个贴一共280分,我马上结贴. 你好,dada20042030,下面这个帖子里面有附件,http://topic.csdn.net/u/20080319/10/1163a757-f29c-4555-8def-1acd120c7eb4.html这个帖子也是我发的``上次你有帮我改过一次``,但不是我想要的那种结果.麻烦你再帮帮忙```谢谢``` 测试下下,看看显示下拉列表的逻辑,没简化,我测试可以<?php//根据id取得相关变量/*$id=$_GET['id'];$conn=mysql_connect("localhost","root","passport");mysql_select_db("novel");mysql_query("set names 'utf8'");$sql="select * from table where id='$id'";mysql_connect($sql,$conn);while($row=mysql_fetch_row($result)){ $dprovince=$row['provincecode']; //山西省$dcity=$row['citycode']; //大同市$darea=$row['areacode'];}*///娴嬭瘯鍙橀噺涓?缁勮褰曟樉绀?//测试值$dprovince="140000"; //山西省$dcity='140200'; //大同市$darea='140227'; //大同县//if($id)?><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script type="text/javascript">var xmlHttp;var requestType="";function createXMLHttpRequest(){ if(window.ActiveXObject) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest) { xmlHttp=new XMLHttpRequest(); }}function queryCity(citycode){ createXMLHttpRequest(); type="city"; var url="data.php?provincecode="+citycode; xmlHttp.open("GET",url,true); xmlHttp.onreadystatechange=handleStateChange; xmlHttp.send(null);}function queryArea(citycode){ createXMLHttpRequest(); type="area"; var url="data.php?citycode="+citycode; xmlHttp.open("GET",url,true); xmlHttp.onreadystatechange=handleStateChange; xmlHttp.send(null);}function handleStateChange(){ if(xmlHttp.readystate==4){ if(xmlHttp.status==200){ if(type=="city"){ showcity(); }else if(type="area"){ showarea(); } } }}function showcity(){ document.getElementById("city").innerHTML=xmlHttp.responseText; document.getElementById("area").innerHTML="";}function showarea(){ document.getElementById("area").innerHTML=xmlHttp.responseText;}</script></head><body><?PHP$conn=mysql_connect("localhost","root","passport");mysql_select_db("novel");mysql_query("set names 'utf8'");$sql="select * from province";$result=mysql_query($sql);echo "<from id='form1'>";echo "<select id='province' onchange='queryCity(this.options[this.selectedIndex].value)'>";//濡傛灉鎻愬彇鍑烘潵鐨勭渷鍊煎瓨鍦?if($dprovince){ echo "<option value='-1' >璇烽?夋嫨鐪佷唤</option>";}else{ echo "<option value='-1' selected>璇烽?夋嫨鐪佷唤</option>";}while($row=mysql_fetch_row($result)){ if($row[1]==$dprovince){ echo "<option value='$row[1]' selected>$row[2]</option>"; }else{ echo "<option value='$row[1]'>$row[2]</option>"; }}echo "</select>";echo '</span>';//鍩庡競浠g爜echo "<span id='city'>";echo "<select onchange='queryArea(this.options[this.selectedIndex].value)'>";if($dprovince){ $sql="select * from city where provincecode=$dprovince"; $result=mysql_query($sql,$conn); if($dcity){ echo "<option value='-1' >璇烽?夋嫨鍩庡競</option>"; }else{ echo "<option value='-1' selected>璇烽?夋嫨鍩庡競</option>"; } while($row=mysql_fetch_row($result)){ if($row[1]==$dcity){ echo "<option value='$row[1]' selected>$row[2]</option>"; }else{ echo "<option value='$row[1]'>$row[2]</option>"; } }}echo "</select>";echo '</span>';//鏄剧ず鍦板尯echo "<span id='area'>";if($dprovince && $dcity){ $sql="select * from area where citycode=$dcity"; $result=mysql_query($sql,$conn); echo "<select>"; if($darea){ echo "<option value='-1' >璇烽?夋嫨鍘垮尯</option>"; }else{ echo "<option value='-1' selected>璇烽?夋嫨鍘垮尯</option>"; } while($row=mysql_fetch_row($result)){ if($row[1]==$darea){ echo "<option value='$row[1]' selected>$row[2]</option>"; }else{ echo "<option value='$row[1]'>$row[2]</option>"; } }}echo '</span>';echo "</form>";?></body></html> 搞定了没.没搞定我可以来掺和掺和.通常这类情况我们用json 等类型数据做中间层来处理.客户端直接解析,然后发到服务器端修改数据库,然后刷资源文件.比较适合数据量不大的级联应用. 测试可以吗?$dprovince="140000"; //山西省$dcity='140200'; //大同市$darea='140227'; 如果你的数据取出来的不是代码而是名称,要转换成代码才行! 这个例子还较常用的,作为作业练习还是不错的!我写的这个只是能正确显示,级别低!strike_un有好的方法吗?通常这类情况我们用json 等类型数据做中间层来处理.客户端直接解析,然后发到服务器端修改数据库,然后刷资源文件!如果有例子的话可以学习一下! fxs_2008 这个是可以获到原来已选择值,但获取到之后,失去了联动菜单的功能,又无法像原来那样选择别的城市进行修改,麻再帮帮忙```能不能在获取到原来已选的值的同时,还能像原为那样还有联动菜单的功能,选择别的城市进行修改 我在IE下测试是可以的这个只判定,如果有GET相关变量,就进行第一次初显(显示三个),其他的不变,仍可联动只是在初显时要三个全显示,如果你重新选择,则是重新联动的如果你还想显示原始的三个,可以刷新一下 你把data.php中的数据连接密码改为你自已的,仍要用那个页! smarty模板 现急招php工程师一名 我要崩溃了。。。新手求救。。。 请问用什么语言做网站有钱图 如何传递javascript的变量 用php发送SMS的类。 菜鸟问题:请问在linux系统下我写的php程序显示的汉字怎么都变成了"???" 求助! 是PHP的配置问题还是主机问题 DZ提示 DIY模板目录不正确 求救,A.php 引入b.php,无法取得b下面aclass的属性 请大家帮忙看看。急!! PHP中实现不同文件下的调用
文件内容如下:
index.php<?php
if($_GET['act']=='insert')
{
echo "one-value:".$_POST['province_one']."<br>";
echo "two-value:".$_POST['province_two']."<br>";
echo "three-value".$_POST['province_three']."<br>";
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
var xmlHttp;
var requestType="";
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}
}
function queryCity(citycode){
createXMLHttpRequest();
type="city";
var url="data.php?provincecode="+citycode;
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.send(null);
}function queryArea(citycode){
createXMLHttpRequest();
type="area";
var url="data.php?citycode="+citycode;
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.send(null);
}function handleStateChange(){
if(xmlHttp.readystate==4){
if(xmlHttp.status==200){
if(type=="city"){
showcity();
}else if(type="area"){
showarea();
}
}
}
}function showcity(){
document.getElementById("city").innerHTML=xmlHttp.responseText;
document.getElementById("area").innerHTML="";
}
function showarea(){
document.getElementById("area").innerHTML=xmlHttp.responseText;
}
</script>
</head>
<body>
<?php
$conn=mysql_connect("localhost","root","2260375");
mysql_select_db("novel");
mysql_query("set names 'utf8'");
$sql="select * from province";
$result=mysql_query($sql);
echo "<form name='form1' action='?act=insert' method='post'>\n";
echo "<select id='province' name='province_one' onchange='queryCity(this.options[this.selectedIndex].value)'>\n";
echo "<option value='-1' selected>请?择省份</option>\n";
while($row=mysql_fetch_row($result)){
echo "<option value='$row[1]'>$row[2]</option>\n";
}
echo "</select>\n";
echo "<span id='city'></span>\n";
echo "<span id='area'></span>\n";
echo "<input type='submit'>";
echo "</form>\n";
?>
</body>
</html>
Data.php<?
$conn=mysql_connect("localhost","root","2260375");
mysql_select_db("novel");
mysql_query("set names 'utf8'");
if($provincecode!=""&&$provincecode!=650000&&$provincecode!=710000&&$provincecode!=810000&&$provincecode!=820000&&$provincecode!=110000&&$provincecode!=120000&&$provincecode!=310000&&$provincecode!=500000){
$sql="select * from city where provincecode=$provincecode";
$result=mysql_query($sql);
echo "<select onchange='queryArea(this.options[this.selectedIndex].value)' name='province_two'>\n";
echo "<option value='-1' selected>ffsdfsf</option>\n";
while($row=mysql_fetch_row($result)){
echo "<option value='$row[1]'>$row[2]</option>\n";
}
echo "</select>\n";
}
if($citycode!=""){
$sql="select * from area where citycode=$citycode";
$result=mysql_query($sql);
echo "<select name='province_three'>\n";
echo "<option value='-1' selected>fsdfsfs</option>\n";
while($row=mysql_fetch_row($result)){
echo "<option value='$row[1]'>$row[2]</option>\n";
}
echo "</select>\n";
}
?>
我的意思是````比如现在选择的是:福建省-福州-长乐
将数据存入数据库里面了是没问题的```
如果要改变现在已选的值,
就要获取显示原来已选的:福建省-福州-长乐
再进行更改
但我无法将已选值,附值到菜单中,
麻烦 dada20042030 再帮帮忙```谢谢
index.php<?php
if($_GET['act']=='insert')
{
echo "one-value:".$_POST['province']."<br>";
echo "two-value:".$_POST['city']."<br>";
echo "three-value".$_POST['area']."<br>";
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
var xmlHttp;
var requestType="";
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}
}
function queryCity(citycode){
createXMLHttpRequest();
type="city";
var url="data.php?provincecode="+citycode;
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.send(null);
}function queryArea(citycode){
createXMLHttpRequest();
type="area";
var url="data.php?citycode="+citycode;
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.send(null);
}function handleStateChange(){
if(xmlHttp.readystate==4){
if(xmlHttp.status==200){
if(type=="city"){
showcity();
}else if(type="area"){
showarea();
}
}
}
}function showcity(){
var return_value=xmlHttp.responseText.split('|');
document.getElementById("city").length=0;
for(var i=0;i<return_value.length;i++)
{
new_option=return_value[i].split(',');
option_text=new_option[0];
option_value=new_option[1];
document.getElementById("city").options.add(new Option(option_value,option_text));
}
}
function showarea(){
document.getElementById("area").length=0;
var return_value=xmlHttp.responseText.split('|');
for(var i=0;i<return_value.length;i++)
{
new_option=return_value[i].split(',');
option_text=new_option[0];
option_value=new_option[1];
document.getElementById("area").options.add(new Option(option_value,option_text));
}
}
function get_value(action)
{
/*
获取到数据以后就用ajax去插入和更新。要不然表单提交以后就会刷新的了。
*/
var provinces=document.form1.province.value;
var citys=document.form1.city.value;
var areas=document.form1.area.value;
alert("进行的动作是:"+action);
alert("省ID:"+provinces);
alert("市ID:"+citys);
alert("区域ID:"+areas);
}
</script>
</head>
<body>
<?php
$conn=mysql_connect("localhost","root","2260375");
mysql_select_db("novel");
mysql_query("set names 'utf8'");
$sql="select * from province";
$result=mysql_query($sql);
?>
<form action="?act=insert" method="POST" name="form1" onsubmit="set_value();">
<select onchange='queryCity(this.options[this.selectedIndex].value)' id='province' name="province">
<?php
while($row=mysql_fetch_row($result)){
echo "<option value='$row[1]'>$row[2]</option>\n";
}
?>
</select>
<select id="city" onchange='queryArea(this.options[this.selectedIndex].value)' name="city"></select>
<select id="area" name="area"></select>
<input type="button" onclick="get_value('insert')" value="insert">
<input type="button" onclick="get_value('update')" value="update">
</form>
</body>
</html>data.php<?
$conn=mysql_connect("localhost","root","2260375");
mysql_select_db("novel");
mysql_query("set names 'utf8'");
if($provincecode!=""&&$provincecode!=650000&&$provincecode!=710000&&$provincecode!=810000&&$provincecode!=820000&&$provincecode!=110000&&$provincecode!=120000&&$provincecode!=310000&&$provincecode!=500000){
$sql="select * from city where provincecode=$provincecode";
$result=mysql_query($sql);
while($row=mysql_fetch_row($result)){
$str.=$row[1].",".$row[2]."|";
}
echo $str;
}
if($citycode!=""){
$sql="select * from area where citycode=$citycode";
$result=mysql_query($sql);
while($row=mysql_fetch_row($result)){
$str.=$row[1].",".$row[2]."|";
}
echo $str;
}
?>
这不是我想要的`麻烦 dada20042030 再帮忙看看,下面有下例子,我在那里面说的很清楚,http://www.51chinajz.com/test/index.html希望能抽点时间再帮小弟看看.只要能帮忙实现这个功能``三个贴一共280分,我马上结贴.
http://topic.csdn.net/u/20080319/10/1163a757-f29c-4555-8def-1acd120c7eb4.html
这个帖子也是我发的``
上次你有帮我改过一次``,但不是我想要的那种结果.
麻烦你再帮帮忙```谢谢```
<?php
//根据id取得相关变量
/*$id=$_GET['id'];
$conn=mysql_connect("localhost","root","passport");
mysql_select_db("novel");
mysql_query("set names 'utf8'");
$sql="select * from table where id='$id'";
mysql_connect($sql,$conn);
while($row=mysql_fetch_row($result)){
$dprovince=$row['provincecode']; //山西省
$dcity=$row['citycode']; //大同市
$darea=$row['areacode'];
}*///娴嬭瘯鍙橀噺涓?缁勮褰曟樉绀?
//测试值$dprovince="140000"; //山西省
$dcity='140200'; //大同市
$darea='140227'; //大同县
//if($id)
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
var xmlHttp;
var requestType="";
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}
}
function queryCity(citycode){
createXMLHttpRequest();
type="city";
var url="data.php?provincecode="+citycode;
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.send(null);
}function queryArea(citycode){
createXMLHttpRequest();
type="area";
var url="data.php?citycode="+citycode;
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.send(null);
}function handleStateChange(){
if(xmlHttp.readystate==4){
if(xmlHttp.status==200){
if(type=="city"){
showcity();
}else if(type="area"){
showarea();
}
}
}
}function showcity(){
document.getElementById("city").innerHTML=xmlHttp.responseText;
document.getElementById("area").innerHTML="";
}
function showarea(){
document.getElementById("area").innerHTML=xmlHttp.responseText;
}
</script>
</head>
<body>
<?PHP
$conn=mysql_connect("localhost","root","passport");
mysql_select_db("novel");
mysql_query("set names 'utf8'");
$sql="select * from province";
$result=mysql_query($sql);
echo "<from id='form1'>";echo "<select id='province' onchange='queryCity(this.options[this.selectedIndex].value)'>";
//濡傛灉鎻愬彇鍑烘潵鐨勭渷鍊煎瓨鍦?
if($dprovince){
echo "<option value='-1' >璇烽?夋嫨鐪佷唤</option>";
}else{
echo "<option value='-1' selected>璇烽?夋嫨鐪佷唤</option>";
}while($row=mysql_fetch_row($result)){
if($row[1]==$dprovince){
echo "<option value='$row[1]' selected>$row[2]</option>";
}else{
echo "<option value='$row[1]'>$row[2]</option>";
}
}echo "</select>";echo '</span>';
//鍩庡競浠g爜
echo "<span id='city'>";
echo "<select onchange='queryArea(this.options[this.selectedIndex].value)'>";
if($dprovince){
$sql="select * from city where provincecode=$dprovince";
$result=mysql_query($sql,$conn);
if($dcity){
echo "<option value='-1' >璇烽?夋嫨鍩庡競</option>"; }else{
echo "<option value='-1' selected>璇烽?夋嫨鍩庡競</option>";
} while($row=mysql_fetch_row($result)){
if($row[1]==$dcity){
echo "<option value='$row[1]' selected>$row[2]</option>";
}else{
echo "<option value='$row[1]'>$row[2]</option>";
}
}
}
echo "</select>";echo '</span>';
//鏄剧ず鍦板尯echo "<span id='area'>";if($dprovince && $dcity){
$sql="select * from area where citycode=$dcity";
$result=mysql_query($sql,$conn);
echo "<select>";
if($darea){
echo "<option value='-1' >璇烽?夋嫨鍘垮尯</option>";
}else{
echo "<option value='-1' selected>璇烽?夋嫨鍘垮尯</option>";
} while($row=mysql_fetch_row($result)){
if($row[1]==$darea){
echo "<option value='$row[1]' selected>$row[2]</option>";
}else{
echo "<option value='$row[1]'>$row[2]</option>";
}
}
}
echo '</span>';echo "</form>";?>
</body>
</html>
没搞定我可以来掺和掺和.
通常这类情况我们用json 等类型数据做中间层来处理.客户端直接解析,然后发到服务器端修改数据库,然后刷资源文件.比较适合数据量不大的级联应用.
$dprovince="140000"; //山西省
$dcity='140200'; //大同市
$darea='140227'; 如果你的数据取出来的不是代码而是名称,要转换成代码才行!
我写的这个只是能正确显示,级别低!strike_un有好的方法吗?
通常这类情况我们用json 等类型数据做中间层来处理.客户端直接解析,然后发到服务器端修改数据库,然后刷资源文件!如果有例子的话可以学习一下!
但获取到之后,失去了联动菜单的功能,
又无法像原来那样选择别的城市进行修改,
麻再帮帮忙```
能不能在获取到原来已选的值的同时,
还能像原为那样还有联动菜单的功能,
选择别的城市进行修改
这个只判定,如果有GET相关变量,就进行第一次初显(显示三个),其他的不变,仍可联动
只是在初显时要三个全显示,如果你重新选择,则是重新联动的
如果你还想显示原始的三个,可以刷新一下
中的数据连接密码改为你自已的,仍要用那个页!