怎么实现在select中选完以后在下一级select自动显示和上一级相关的数据行

WBOY
Release: 2016-06-20 12:37:28
Original
1439 people have browsed it

ajax不太懂,怎么把选完第一级select的选项提交给PHP处理


回复讨论(解决方案)

参考: http://blog.chinaunix.net/uid-7254998-id-145002.html


例子里的action为空,新手是肯定不知道问题出在哪里的。。。

对啊,我把例子里面的全复制到一个php文件里没成功,form的action我要填到另一个处理页面,我想一点第一个下拉列表就根据选的值无刷新改变第二个列表的选项。

使用 jq 就很简单

<?phpif($_SERVER['REQUEST_METHOD'] == "POST") {  $d = array(    array(1,2,3,4),    array(11,12,13,14),    array(21,22,23,24),    array(31,32,33,34),    array(41,42,43,44),  );  foreach($d[$_POST['s1']] as $v) echo "<option value=$v>$v</option>";  exit;}?><script src=scripts/jquery-1.8.3.min.js></script><script>$(function() {  $('#s1').load(location.href, {s1 : 0});  $('#s1').change(function() {    $(this).next().load(location.href, {s1:$(this).val()});  });});</script><select name=s1 id=s1></select><select name=s2 id=s2></select>
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!