im new to php . plz help. i have a page where people fill in a form and check on checkboxes. i also have a page where i edit. i want to know if its possible that on my edit page i could see the checked box checked ? example if "checkbox male" was checked and i want to edit it. on my edit page , can it appear checked already? how if possible?
ernesto22 0 Newbie Poster
Recommended Answers
Jump to Post<?php $chk = (isset($sex) && $sex == 1) ? array('','checked ') : array('checked ', ''); ?> <input type='radio' value='0' name='sex' id='female' <?=$chk[0]?>/>Female <input type='radio' value='1' name='sex' id='male' <?=$chk[1]?>/>Male
$sex
holds the value of gender retrieved from DB.Your example seems to be using checkboxes - …
Jump to PostHere's a quite and dirty function just knocked up with a few examples. Should work for select or radio. To get ti to work for select, change 'checked ' to 'selected ':
function getCheckedArray($options, $chosen, $compareValues=true) { $fills = array_fill(0,count($options),''); if(!$compareValues) { $tmp = array_search($chosen, array_values(array_flip($options))); }else{ …
All 7 Replies
Adrian_5 1 Light Poster
ernesto22 0 Newbie Poster
toxicandy 2 Junior Poster

diafol
ernesto22 0 Newbie Poster

diafol

diafol
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.