Jump to content


Photo

is there a better way to set radio buttons checked from value in DB?


  • Please log in to reply
No replies to this topic

#1 nissa

nissa
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 03 August 2006 - 01:59 PM

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

	<?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);
         		?>

Thanks in advance!

Nissa




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users