二级联动菜单

现在编码是唯一的问题了XML HTML方式都实验过
DynamicList.html
CODE:


<!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;>

<html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;>

<head>

<meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=gb2312&#34; />

<title>无标题文桁</title>

<script type=&#34;text/javascript&#34;>

var xmlHttp;



function cr&#101;ateXMLHttpRequest(){

      if (window.ActiveXObject) {

              xmlHttp = new ActiveXObject (&#34;Microsoft.XMLHTTP&#34;);

      }

      else if (window.XMLHttpRequest) {

           xmlHttp = new XMLHttpRequest () ;

      }

}



function refreshMenuList() {

     var classf = document.getElementById(&#34;classf&#34;).value;

   

   if (classf == &#34;&#34;) {

        clearmenu();

      return;

  }

  

  var url = &#34;DynamicList.php?&#34; + cr&#101;ateQueryString(classf) + &#34;&ts=&#34; + new Date().getTime();

  

  cr&#101;ateXMLHttpRequest();

  xmlHttp.onreadystatechange = handleStateChange;

  xmlHttp.open(&#34;GET&#34;, url, true);

  xmlHttp.send(null);

}



function cr&#101;ateQueryString(classf) {

     var queryString = &#34;classf=&#34; + classf;

   return queryString;

}



function handleStateChange() {

     if (xmlHttp.readyState == 4) {

            if (xmlHttp.status == 200) {

                 document.getElementById(&#34;class&#34;).innerHTML = xmlHttp.responseText;

            }

     }

}

</script>

</head>



<body>

<table width=&#34;400&#34; border=&#34;0&#34; cellspacing=&#34;0&#34; cellpadding=&#34;0&#34;>

  <tr>

    <td width=&#34;53&#34;>classf</td>

    <td width=&#34;347&#34;><sel&#101;ct name=&#34;classf&#34; id=&#34;classf&#34; onchange=&#34;refreshMenuList();&#34;>

      <option value=&#34;1&#34;>学院新闻</option>

      <option value=&#34;2&#34;>学生新闻</option>

    </sel&#101;ct>

    </td>

  </tr>

  <tr>

    <td>classs</td>

    <td>

      <div id=&#34;class&#34;></div>

    </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

  </tr>

</table>

</body>

</html>



DynamicList.php
CODE:


<?php

$hostname_web 
= &#34;localhost&#34;;

$database_web = &#34;ciseweb&#34;;

$username_web = &#34;root&#34;;

$password_web = &#34;&#34;;

$web mysql_pconnect($hostname_web$username_web$password_webo&#114; trigger_error(mysql_error(),E_USER_ERROR); 



if (isset($_GET['classf'])) {

  
$colname_class = (get_magic_quotes_gpc()) ? $_GET['classf'] : addslashes($_GET['classf']);

}

mysql_sel&#101;ct_db($database_web, $web);

$query_class sprintf(&#34;Sel&#101;ct * FROM newsclass Wh&#101;re classf = %s o&#114;DER BY `class` ASC&#34;, $colname_class);

$class mysql_query($query_class$webo&#114; die(mysql_error());

$row_class mysql_fetch_assoc($class);

$totalRows_class mysql_num_rows($class);

?>

二级分类

<sel&#101;ct name=&#34;sel&#101;ct&#34;>

<? do {?>

 <option value=&#34;<? echo $row_class['class']?>;&#34;><? echo $row_class['classname'];?></option>

<? } while ($row_class mysql_fetch_assoc($class));?>

</sel&#101;ct>

引用通告地址: http://www.anycc.com/blog/trackback.php?tbID=65&extra=9332b1
标签:  AJAX
评论: 0 | 引用: 0 | 阅读: 1347
发表评论
昵 称: 密 码:
网 址: 邮 箱:
验证码: 验证码图片 选 项:
头 像:
内 容: