eldan88 Posted September 7, 2014 Share Posted September 7, 2014 I am echoing out 2 radio input fields in a foreach statement. I would like to have the first option checked in all the radio input fields that gets echoed out. But for some reason it marks the radio input field "checked" all the way in the bottom. (The last one) How can I make it so that every input field that gets echoed out will be marked checked? Below is my code. Thank you for your help foreach ($menu_cat_options as $menu_cat_option){ <input type="radio" checked="checked" name="display_type" value="radio" >Radio <br> <input type="radio" name="display_type" value="checkbox">Check Box } Quote Link to comment Share on other sites More sharing options...
Solution requinix Posted September 7, 2014 Solution Share Posted September 7, 2014 You can't have more than one radio button checked in the same group (ie, with the same name). Use checkboxes instead. Note that you need to change the name to "display_type[]": those added []s mean that $_POST["display_type"] will be an array of what was checked. Without the []s you'll only get one value. Quote Link to comment Share on other sites More sharing options...
eldan88 Posted September 8, 2014 Author Share Posted September 8, 2014 ahh okay. Thank you very much Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.