用PHP实现真正的连动下拉列表

下面的两个文件copy到同一个文件下,通过web路径访问index.html看看吧,这个是通过iframe来实现的连动更新,list.php目前的内容比较简单,你看通过list.php来进行数据库查询,然后显示出查询的结果列表。

index.html

  1. <body> 
  2. <form name="myfrm"> 
  3. <select name="mlist" onchange="changes();"> 
  4. <option value="0">请选择…</option> 
  5. <option value="北京">北京</option> 
  6. <option value="通化">通化</option> 
  7. </select>&nbsp; 
  8. <select name="slist"> 
  9. </select> 
  10. <iframe id="frame" src="list.php?city=" style="display:none;"></iframe> 
  11. <script language="javascript"> 
  12. function changes(){ 
  13. frame.location.href = "list.php?city=" document.myfrm.mlist.value; 
  14. </script> 
  15. </form> 
  16. </body> 

list.php

  1. <?php 
  2. $data = array("北京"=>array("小强","旺财","小强他爹"), 
  3. "通化"=>array("小温","小宋","他们儿子"),); 
  4.  
  5. $city = $_GET["city"]; 
  6.  
  7. $result = $data[$city]; 
  8.  
  9. $str = "<script language="javascript">list = parent.document.myfrm.slist;list.length = 0;"
  10.  
  11. if($result==null) 
  12. $str .= "tmp = new Option("……", "");list.options[0] = tmp;"
  13. else 
  14. foreach($result as $i => $value
  15. $str .= "tmp = new Option("{$value}", "{$value}");list.options[$i] = tmp;"
  16. $str .= "</script>"
  17.  
  18. echo $str
  19. ?> 
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!

波比源码 » 用PHP实现真正的连动下拉列表

131 评论

  1. order sildenafil 50mg without prescription suhagra 100mg pill purchase estrace without prescription

  2. buy catapres 0.1mg for sale minocin sale oral tiotropium bromide 9mcg

  3. benicar order online calan 120mg usa buy diamox 250 mg sale

  4. buy molnunat generic molnunat ca order prevacid generic

  5. purchase colchicine pills casino slot casino online real money

  6. order generic tadalafil 10mg cialis 10mg cost order generic ciprofloxacin 500mg

  7. real money spins online cialis for women order tadalafil 40mg sale

  8. oral sildenafil 100mg budesonide pill buy rhinocort without prescription

  9. buy clarithromycin 500mg for sale meclizine brand buy meclizine 25 mg for sale

  10. cheap digoxin 250mg lanoxin tablet order molnupiravir 200mg online cheap

  11. doxycycline 200mg without prescription doxycycline uk methylprednisolone 8 mg otc

  12. buy requip 2mg pills buy ropinirole purchase trandate generic

  13. order cialis 5mg red ed pill buy erectile dysfunction medication

  14. deltasone 10mg oral order accutane oral amoxicillin 1000mg

  15. zetia 10mg canada ezetimibe pill cheap methotrexate 10mg

  16. praziquantel for sale buy periactin purchase periactin generic

  17. purchase xenical without prescription zovirax sale allopurinol 100mg cost

  18. buy cialis 10mg for sale Buy viagra us buy generic sildenafil

  19. order duricef without prescription lamivudine drug finasteride 5mg usa

  20. estradiol online buy cost lamotrigine order minipress 2mg online cheap

  21. order flagyl 400mg online order flagyl 200mg buy keflex 125mg without prescription

  22. ivermectin 6mg without prescription buy ed pills gb order deltasone 5mg online cheap

发表评论

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系站长
赞助VIP 享更多特权,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡