PHP 使用checkbox ,select 多选,名称数组的取值和赋值 朱雀 2022-08-11 15:30 156阅读 0赞 <html> <head> </head> <body > <?php $e\_ary=array('PHP','C++') ?> <form name="form1" action="testsubmit.php" method="post"> <input name="choose\[\]" type="checkbox" value="PHP" <?php if(is\_array($e\_ary))\{ echo in\_array('PHP',$e\_ary)?'checked':'';\} ?>>PHP <input name="choose\[\]" type="checkbox" value="VB" <?php if(is\_array($e\_ary))\{ echo in\_array('VB',$e\_ary)?'checked':'';\} ?>>VB <input name="choose\[\]" type="checkbox" value="C++" <?php if(is\_array($e\_ary))\{ echo in\_array('C++',$e\_ary)?'checked':'';\} ?>>C++ <select name=select\[\] multiple> <option value="PHP"<?php if(is\_array($e\_ary))\{ echo in\_array('PHP',$e\_ary)?'selected':'';\} ?>>PHP</option> <option value="VB" <?php if(is\_array($e\_ary))\{ echo in\_array('VB',$e\_ary)?'selected':'';\} ?>>VB</option> <option value="C++" <?php if(is\_array($e\_ary))\{ echo in\_array('C++',$e\_ary)?'selected':'';\} ?>>C++</option> </select> <input name="submit" type="submit" value="submit"> </form> </body> </html>
还没有评论,来说两句吧...