nissa Posted August 3, 2006 Share Posted August 3, 2006 Hello,I am new to web development and I'm trying to set which radio button is checked from my DB. I have it set up so that it works but it seems kinda sloppy code to me. I can't seem to find anything that will tell me how to set the radio to checked from the DB. I'm using Ajax to save and it works fine. Is there a better way to do this without the repetition of code? (renewalrequest is set as number(1) in the table)Edit: actually it doesn't work - the values are the same for all radios of the same name[code] <?php $statement = OCIParse($dbConnect, "select renewalrequest from rip_project_details where rip=".$ripid); OCIExecute($statement); if (OCIFetchInto($statement, $row)) { if($row[0] == 0){ ?><tr><td><input type="radio" name="renewalrequest" [color=red]checked[/color] value="0" id="servicerenewal" onclick="ischanged(this); setChanged()"><label for="servicerenewal">Managed Service Renewal?</label></td></tr><tr><td><input type="radio" name="renewalrequest" value="1" id="softwarerenewal" onclick="ischanged(this); setChanged()"><label for="softwarerenewal">Software Maintenance Renewal?</label></td></tr><tr><td><input type="radio" name="renewalrequest" value="2" id="serverrefresh" onclick="ischanged(this); setChanged()"><label for="serverrefresh">Server Refresh ONLY?</label></td></tr> <?php } else if ($row[0] == 1){ ?><tr><td><input type="radio" name="renewalrequest" value="0" id="servicerenewal" onclick="ischanged(this); setChanged()"><label for="servicerenewal">Managed Service Renewal?</label></td></tr><tr><td><input type="radio" name="renewalrequest" [color=red]checked[/color] value="1" id="softwarerenewal" onclick="ischanged(this); setChanged()"><label for="softwarerenewal">Software Maintenance Renewal?</label></td></tr><tr><td><input type="radio" name="renewalrequest" value="2" id="serverrefresh" onclick="ischanged(this); setChanged()"><label for="serverrefresh">Server Refresh ONLY?</label></td></tr> <?php } else { ?><tr><td><input type="radio" name="renewalrequest" value="0" id="servicerenewal" onclick="ischanged(this); setChanged()"><label for="servicerenewal">Managed Service Renewal?</label></td></tr><tr><td><input type="radio" name="renewalrequest" value="1" id="softwarerenewal" onclick="ischanged(this); setChanged()"><label for="softwarerenewal">Software Maintenance Renewal?</label></td></tr><tr><td><input type="radio" name="renewalrequest" [color=red]checked[/color] value="2" id="serverrefresh" onclick="ischanged(this); setChanged()"><label for="serverrefresh">Server Refresh ONLY?</label></td></tr> <?php } //end inner if } else { ?><tr><td><input type="radio" name="renewalrequest" value="0" id="servicerenewal" onclick="ischanged(this); setChanged()"><label for="servicerenewal">Managed Service Renewal?</label></td></tr><tr><td><input type="radio" name="renewalrequest" value="1" id="softwarerenewal" onclick="ischanged(this); setChanged()"><label for="softwarerenewal">Software Maintenance Renewal?</label></td></tr><tr><td><input type="radio" name="renewalrequest" value="2" id="serverrefresh" onclick="ischanged(this); setChanged()"><label for="serverrefresh">Server Refresh ONLY?</label></td></tr> <?php } ocifreestatement($statement); ?>[/code]Thanks in advance!Nissa 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.