php + js 勾选A select 同步B select

WBOY
Release: 2016-06-23 13:34:44
Original
970 people have browsed it

要如何写勾选A时,B会同步?

<select id="A" name="A" ><?php	$query = $db->query("	SELECT * FROM `select`"); 			foreach($query->result() as $row){	?>  <option value="<?php echo $row->id;?>"><?php echo $row->name;?></option><?php	}?>  </select>            <?php	$query = $db->query("	SELECT * FROM `test`"); 			foreach($query->result() as $row){	?>  <select id="B" name="B[]" ><?php	$query1 = $db->query("	SELECT * FROM `select`"); 			foreach($query1->result() as $row){	?>  <option value="<?php echo $row1->id;?>"><?php echo $row1->name;?></option><?php	}?>  </select><?php	}?> 
Copy after login


回复讨论(解决方案)

请使用ajax

ajax onchange()

首先用js控制,a修改时,b也修改。
然后a onchange时,执行一个ajax,更新db

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