Need help echoing the checked boxes selected by the user

落爺英雄遲暮 提交于 2020-01-06 13:58:52

问题


How to display selected checkbox? I tried but it didnt work

<input type=checkbox value="Administrative"<?php echo ($industry_sector1a == 'Administrative' ? 'selected="selected"' : ''); ?>name="industry_sector1"> Administrative

I use the below for drop down boxes .

 <option value="-1"<?php echo ($native_language == '-1' ? 'selected="selected"' : ''); ?>>----- Please Select -----</option>
                <option value="1"<?php echo ($native_language == '1' ? 'selected="selected"' : ''); ?>>English - United States</option>

回答1:


<input type="checkbox" checked="checked" name="foo" />bar



回答2:


Yo need to use

<input type="checkbox" value="Administrative" <?php echo ($industry_sector1a == 'Administrative') ? 'checked="checked"' : ''; ?> name="industry_sector1"> Administrative


来源:https://stackoverflow.com/questions/5129485/need-help-echoing-the-checked-boxes-selected-by-the-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!