pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <i id='ooahG'><tr id='ooahG'><dt id='ooahG'><q id='ooahG'><span id='ooahG'><b id='ooahG'><form id='ooahG'><ins id='ooahG'></ins><ul id='ooahG'></ul><sub id='ooahG'></sub></form><legend id='ooahG'></legend><bdo id='ooahG'><pre id='ooahG'><center id='ooahG'></center></pre></bdo></b><th id='ooahG'></th></span></q></dt></tr></i><div class="x3xb9nl" id='ooahG'><tfoot id='ooahG'></tfoot><dl id='ooahG'><fieldset id='ooahG'></fieldset></dl></div>
        <bdo id='ooahG'></bdo><ul id='ooahG'></ul>

      <tfoot id='ooahG'></tfoot>

      <small id='ooahG'></small><noframes id='ooahG'>

      <legend id='ooahG'><style id='ooahG'><dir id='ooahG'><q id='ooahG'></q></dir></style></legend>

        ajax php 下拉列表

        ajax php drop down list(ajax php 下拉列表)
          <tbody id='i8rHj'></tbody>

          <bdo id='i8rHj'></bdo><ul id='i8rHj'></ul>
        • <small id='i8rHj'></small><noframes id='i8rHj'>

          <i id='i8rHj'><tr id='i8rHj'><dt id='i8rHj'><q id='i8rHj'><span id='i8rHj'><b id='i8rHj'><form id='i8rHj'><ins id='i8rHj'></ins><ul id='i8rHj'></ul><sub id='i8rHj'></sub></form><legend id='i8rHj'></legend><bdo id='i8rHj'><pre id='i8rHj'><center id='i8rHj'></center></pre></bdo></b><th id='i8rHj'></th></span></q></dt></tr></i><div class="fvjj57x" id='i8rHj'><tfoot id='i8rHj'></tfoot><dl id='i8rHj'><fieldset id='i8rHj'></fieldset></dl></div>
          <tfoot id='i8rHj'></tfoot>

                  <legend id='i8rHj'><style id='i8rHj'><dir id='i8rHj'><q id='i8rHj'></q></dir></style></legend>
                  本文介紹了ajax php 下拉列表的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  有人能告訴我這個網站上的示例代碼有什么問題嗎http://www.x-developer.com/php-scripts/loading-drop-downs-with-ajax-php-and-fetching-values-from-database-without-refreshing-the-page

                  Can some one tell me what's wrong with this example code on this site http://www.x-developer.com/php-scripts/loading-drop-downs-with-ajax-php-and-fetching-values-from-database-without-refreshing-the-page

                  基本上我做的和在 turorial 中完全一樣,問題是第二個下拉列表沒有顯示任何內容.我讀到有人忘記在頁面上添加一些 javascript 的評論之一.我該怎么做?

                  Basically i did exactly the same as in the turorial and the problem is that the 2nd drop down list is no showing anything. I read one of the comments that someone forgot to add in some javascript on the page. How do i do this?

                  我曾嘗試在該網站上發布一個問題,但一周以來沒有人回答,所以我來到了這里.

                  I have tried posting a question on that site but no one answered for a week now so I came here.

                  任何幫助將不勝感激.

                  這是我的 index.php 頁面

                  this is my index.php page

                  <?php
                  include('cn.php');
                  
                  $sql_country = "SELECT * FROM COUNTRY";
                  $result_country = mysql_query($sql_country);
                  
                  echo "<select name='country' onChange='get_cities(this.value)'>"; //get_cities is defined below
                  
                  while($row_country = mysql_fetch_array($result_country))
                  {
                  echo "<option value='".$row_country['id']."'>".$row_country['country']."</option>";
                  }
                  
                  echo "</select>";
                  
                  echo "<select name='city' id='city'></select>"; //We have given id to this dropdown
                  
                  ?>
                  

                  這是我的 get_cities.js 頁面

                  this is my get_cities.js page

                  function get_cities(country_id)
                  {
                  $.ajax({
                     type: "POST",
                     url: "cities.php", /* The country id will be sent to this file */
                     beforeSend: function () {
                    $("#city").html("<option>Loading ...</option>");
                      },
                     data: "country_id="+country_id,
                     success: function(msg){
                       $("#city").html(msg);
                     }
                     });
                   } 
                  

                  這是我的城市.php頁面

                  This is my cities.php page

                  <?php
                  
                  include('cn.php');
                  
                  // Code for cities.php
                  $country_id = $_REQUEST['country_id'];
                  
                  $sql_city = "SELECT * FROM CITY WHERE country_id = '".$country_id."'";
                  $result_city = mysql_query($sql_city);
                  echo "<select name='city'>";
                  
                  while($row_city = mysql_fetch_array($result_city))
                  {
                  echo "<option value='".$row_city['id']."'>".$row_city['city']."</option>";
                  }
                  
                  echo "</select>";
                  
                  ?>
                  

                  包含的cn.php"只是我與數據庫的連接.

                  The included 'cn.php' is just my connection to the database.

                  推薦答案

                  //Index.php
                  <?php
                  $conn = mysql_connect("localhost", "root", "root");
                  $db = mysql_select_db("country_example", $conn);
                  
                  $sql_country = "SELECT * FROM country";
                  $result_country = mysql_query($sql_country);
                  
                  ?>
                  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                  <html xmlns="http://www.w3.org/1999/xhtml">
                  <head>
                  <title>Country List</title>
                  </head>
                  <body>
                  <?php 
                  
                  echo "<select name='country' onChange='get_cities(this.value)'>";
                  
                  while($row_country = mysql_fetch_array($result_country))
                  {
                      echo "<option value='".$row_country['id']."'>".$row_country['country']."</option>";
                  }
                  echo "</select>";
                  echo "<div id='cityLayer'><select name='city' id='city'></select></div>";
                  ?>
                      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
                      <script type="text/javascript"> 
                      function get_cities($country_id){
                       $.ajax({
                           url : "city.php?country_id="+$country_id,
                           cache : false,
                           beforeSend : function (){
                                //Show a message
                           },
                           complete : function($response, $status){
                               if ($status != "error" && $status != "timeout") {
                                   $('#cityLayer').html($response.responseText);
                               }
                           },
                           error : function ($responseObj){
                               alert("Something went wrong while processing your request.
                  
                  Error => "
                                   + $responseObj.responseText);
                           }
                       }); 
                      }
                   </script>
                  </body>
                  </html>
                  
                  //City.php
                  <?php
                  
                  $conn = mysql_connect("localhost", "root", "root");
                  $db = mysql_select_db("country_example", $conn);
                  
                  $country_id = $_REQUEST['country_id'];
                  $sql_city = "SELECT * FROM cities WHERE country_id = '".$country_id."'";
                  $result_city = mysql_query($sql_city);
                  
                  echo "<select name='city'>";
                  while($row_city = mysql_fetch_array($result_city))
                  {
                      echo "<option value='".$row_city['id']."'>".$row_city['city']."</option>";
                  }
                  echo "</select>";
                  ?>
                  

                  這篇關于ajax php 下拉列表的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                  <legend id='arhxR'><style id='arhxR'><dir id='arhxR'><q id='arhxR'></q></dir></style></legend>
                  1. <small id='arhxR'></small><noframes id='arhxR'>

                      1. <i id='arhxR'><tr id='arhxR'><dt id='arhxR'><q id='arhxR'><span id='arhxR'><b id='arhxR'><form id='arhxR'><ins id='arhxR'></ins><ul id='arhxR'></ul><sub id='arhxR'></sub></form><legend id='arhxR'></legend><bdo id='arhxR'><pre id='arhxR'><center id='arhxR'></center></pre></bdo></b><th id='arhxR'></th></span></q></dt></tr></i><div class="t57r5tt" id='arhxR'><tfoot id='arhxR'></tfoot><dl id='arhxR'><fieldset id='arhxR'></fieldset></dl></div>
                          <tfoot id='arhxR'></tfoot>

                            <tbody id='arhxR'></tbody>
                            <bdo id='arhxR'></bdo><ul id='arhxR'></ul>

                            主站蜘蛛池模板: 【365公司转让网】公司求购|转让|资质买卖_股权转让交易平台 | 网站建设-网站制作-网站设计-网站开发定制公司-网站SEO优化推广-咏熠软件 | 上海电子秤厂家,电子秤厂家价格,上海吊秤厂家,吊秤供应价格-上海佳宜电子科技有限公司 | 数控车床-立式加工中心-多功能机床-小型车床-山东临沂金星机床有限公司 | 示波器高压差分探头-国产电流探头厂家-南京桑润斯电子科技有限公司 | SDG吸附剂,SDG酸气吸附剂,干式酸性气体吸收剂生产厂家,超过20年生产使用经验。 - 富莱尔环保设备公司(原名天津市武清县环保设备厂) | 硬齿面减速机_厂家-山东安吉富传动设备股份有限公司 | 宿松新闻网 宿松网|宿松在线|宿松门户|安徽宿松(直管县)|宿松新闻综合网站|宿松官方新闻发布 | 壹作文_中小学生优秀满分作文大全 | 电气控制系统集成商-PLC控制柜变频控制柜-非标自动化定制-电气控制柜成套-NIDEC CT变频器-威肯自动化控制 | 沉降天平_沉降粒度仪_液体比重仪-上海方瑞仪器有限公司 | 湖北省煤炭供应链综合服务平台| 食品质构分析仪-氧化诱导分析仪-瞬态法导热系数仪|热冰百科 | 艾乐贝拉细胞研究中心 | 国家组织工程种子细胞库华南分库 | 二氧化碳/活性炭投加系统,次氯酸钠发生器,紫外线消毒设备|广州新奥 | 玉米加工设备,玉米深加工机械,玉米糁加工设备.玉米脱皮制糁机 华豫万通粮机 | 湖南自考_湖南自学考试| 深圳激光打标机_激光打标机_激光焊接机_激光切割机_同体激光打标机-深圳市创想激光科技有限公司 深圳快餐店设计-餐饮设计公司-餐饮空间品牌全案设计-深圳市勤蜂装饰工程 | 广州/东莞小字符喷码机-热转印打码机-喷码机厂家-广州瑞润科技 | 石油/泥浆/不锈钢防腐/砂泵/抽砂泵/砂砾泵/吸砂泵/压滤机泵 - 专业石油环保专用泵厂家 | 山东活动策划|济南活动公司|济南公关活动策划-济南锐嘉广告有限公司 | 定制奶茶纸杯_定制豆浆杯_广东纸杯厂_[绿保佳]一家专业生产纸杯碗的厂家 | PC构件-PC预制构件-构件设计-建筑预制构件-PC构件厂-锦萧新材料科技(浙江)股份有限公司 | 施工电梯_齿条货梯_烟囱电梯_物料提升机-河南大诚机械制造有限公司 | 飞行者联盟-飞机模拟机_无人机_低空经济_航空技术交流平台 | 股票入门基础知识_股票知识_股票投资大师_格雷厄姆网 | 合肥风管加工厂-安徽螺旋/不锈钢风管-通风管道加工厂家-安徽风之范 | 定量包装秤,吨袋包装称,伸缩溜管,全自动包装秤,码垛机器人,无锡市邦尧机械工程有限公司 | 玻璃钢格栅盖板|玻璃钢盖板|玻璃钢格栅板|树篦子-长沙川皖玻璃钢制品有限公司 | 美甲贴片-指甲贴片-穿戴美甲-假指甲厂家--薇丝黛拉 | 塑胶跑道施工-硅pu篮球场施工-塑胶网球场建造-丙烯酸球场材料厂家-奥茵 | 韦伯电梯有限公司 | 分光色差仪,测色仪,反透射灯箱,爱色丽分光光度仪,美能达色差仪维修_苏州欣美和仪器有限公司 | MOOG伺服阀维修,ATOS比例流量阀维修,伺服阀维修-上海纽顿液压设备有限公司 | 断桥铝破碎机_铝合金破碎机_废铁金属破碎机-河南鑫世昌机械制造有限公司 | 蓝米云-专注于高性价比香港/美国VPS云服务器及海外公益型免费虚拟主机 | 泰兴市热钻机械有限公司-热熔钻孔机-数控热熔钻-热熔钻孔攻牙一体机 | 悬浮拼装地板_幼儿园_篮球场_悬浮拼接地板-山东悬浮拼装地板厂家 | 重庆LED显示屏_显示屏安装公司_重庆LED显示屏批发-彩光科技公司 重庆钣金加工厂家首页-专业定做监控电视墙_操作台 | IP检测-检测您的IP质量 | 滤芯,过滤器,滤油机,贺德克滤芯,精密滤芯_新乡市宇清流体净化技术有限公司 |