Get the value of checkbox or select multi-select column in PHP code, a simple example for beginners’ reference.
The complete code is as follows: <html> <head><title>checkbox select取值_bbs.it-home.org</title> </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> Copy after login |