Welcome Guest, Not a member yet? Register   Sign In
validation, radio button, and loops?
#4

[eluser]Thorpe Obazee[/eluser]
Code:
if ($_POST) {
// get post variables
echo $_POST['name'];
}else {
// get database results
echo $db_result->name;
}

the above won't work on radio buttons. you will need to echo a 'selected' so.... set_radio()

Code:
<?php foreach ($clients->result() as $client):?>
<option value="&lt;?php echo $client->id;?&gt;" &lt;?php if ($_POST) { echo $this->validation->set_radio('client', $invoice_detail->client_id);} else { echo( $invoice_detail->client_id == $client->id) ? 'selected' : '';}?&gt;>&lt;?php echo $client->name; ?&gt;</option>
&lt;?php endforeach;?&gt;

the above is if there is something selected from the database already.

Code:
&lt;?php foreach ($clients->result() as $client):?&gt;
<option value="&lt;?php echo $client->id;?&gt;" &lt;?php  echo $this->validation->set_radio('client', $invoice_detail->client_id);?&gt;>&lt;?php echo $client->name; ?&gt;</option>
&lt;?php endforeach;?&gt;

this one is if there is none.


Messages In This Thread
validation, radio button, and loops? - by El Forum - 08-29-2008, 09:51 AM
validation, radio button, and loops? - by El Forum - 08-29-2008, 09:58 AM
validation, radio button, and loops? - by El Forum - 08-29-2008, 02:35 PM
validation, radio button, and loops? - by El Forum - 08-29-2008, 02:42 PM
validation, radio button, and loops? - by El Forum - 08-29-2008, 02:52 PM
validation, radio button, and loops? - by El Forum - 08-29-2008, 03:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB