Prepopulating radio input - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Prepopulating radio input (/showthread.php?tid=11529) |
Prepopulating radio input - El Forum - 09-12-2008 [eluser]Bramme[/eluser] Okay, I'm having a weird problem. Dunno where to go look for the solution though. I'm building an edit form that has several inputs: textboxes, textareas, some checkboxes and a set of radio inputs. Now I want to prepopulate the edit form, which works great for the text bits, but I can't get the radio buttons to prepopulate. Code: if( empty($this->validation->error_string)) { Now I've changed the set_radio thingie (which doesn't work with prepopulated data, as it only looks at $_POST and not at $this->validation) with my own if: Code: <input type="radio" name="rankID" value="<?=$rank['rankID']?>" id="rank-<?=$rank['rankID']?>" <?php if($select_rank == $rank['rankID']) echo 'selected="selected" '; ?>/> Now this works, I can see the selected="selected" code in my source code, it changes correctly when you submit the form but validation fails etc. HOWEVER: it doesn't get selected in the form in the browser itself. Has anybody got any idea what could be causing this? Prepopulating radio input - El Forum - 09-12-2008 [eluser]xwero[/eluser] If you see it changing setting the selected attribute works, or is there something i'm missing here? Prepopulating radio input - El Forum - 09-12-2008 [eluser]Bramme[/eluser] The selected attribute is set. That's the whole weird thing. First I thought it was a FF bug, but it's happening in Chrome too... Sorry for the crappy screenshot. Prepopulating radio input - El Forum - 09-12-2008 [eluser]xwero[/eluser] a radio button doesn't know the selected attribute. It has the checked attribute. sometimes i'm really clueless To make it easier on myself i made these functions Code: function form_selected($value1,$value2) Prepopulating radio input - El Forum - 09-12-2008 [eluser]Bramme[/eluser] Oh god. Stupid me once again. And I even checked on the w3schools xhtml reference if it was selected and not checked. Must've gotten confused and thought I was right. |