复选框值

WBOY
WBOYOriginal
2016-06-23 14:06:46759browse


三个值是从数据库读出来,不让他为空就Ok
代码:


应用类型:

 $arr_app_type =explode(";",$rs["app_types"]); 
 $sql = "select * from app_type where id in (10,4,6) order by id";
 $mysql->query($sql);
 while($row = $mysql->fetch_array()){
?>

 />
 

}
?>


回复讨论(解决方案)

不知道你想问什么

当不选中其一时,提交不成功?

在form 的onsubmit 事件中调用js函数验证就是了

参考一下

<script>function foo(){    var chs=document.getElementsByName('app_types[]');	var counter=0;	for(var i=0;i<chs.length;i++){	     if(chs[i].checked) counter++;	}	if(counter==0) return false;	return true;}</script><form action="" method="post" onsubmit="return foo()"><input  id="app" name="app_types[]" type="checkbox" value="1"><input  id="app" name="app_types[]" type="checkbox" value="2"><input  id="app" name="app_types[]" type="checkbox" value="3"><input type='submit'></form>

谢谢了,稍做了一下逻辑就搞定了

谢谢了,高手们

Statement:
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