Welcome Guest, Not a member yet? Register   Sign In
RadioButton not checked proper.
#1

[eluser]Rocky Mehta[/eluser]
I fetch all the data form the database. if condition true then my checkbox checked proper, but how can i radio button checked if condition true. AT line no 29 my radiobutton condition is true but not checked radio in browser
Controller page:
Code:
function main($venue_facilities_id = 0)
{
$this->load->model('venue_facilities_model');
$data = $this->venue_facilities_model->general();
  
if ($this->input->post('save'))
{
  if ($this->input->post('venue_facilities_id'))
  {
   $this->venue_facilities_model->do_upload();
   $this->venue_facilities_model->update_facility($_FILES['userfile']['name']);
   echo "Data Updated Successfully";
   redirect('http://localhost/venue/index.php/venue_facilities/update/');
  }
  else
  {
   $this->venue_facilities_model->do_upload();
   $this->venue_facilities_model->insert_facility($_FILES['userfile']['name']);
   echo "Data Inserted Successfully";
  }
}
if((int)$venue_facilities_id>0)
{
  $query = $this->venue_facilities_model->get($venue_facilities_id);
  $data['mvenue_facilities_id']['value']=$query['venue_facilities_id'];
  $data['venue_facilities_name']['value'] = $query['venue_facilities_name'];
  $data['venue_facilities_image']['value']=$query['venue_facilities_image'];
  [b]if($query['charges']=='free')   // if condition is true then radiobutton checked but not checked
  {
   //echo 'hiiiiiii';
   $data['charges']['checked'] = TRUE;
   echo set_radio('charges', 'free', TRUE);
  }[/b]
  if($query['charg']=='1')    //If condition true checkbox is checked this is workd.
  {
   $data['charg']['checked'] = TRUE;
  }
  else
  {
   $data['charg']['checked'] = FALSE;
  }    
}
$this->load->view('venue_facilities_view',$data);
}
view page:
Code:
<?php
  echo form_radio("charges", "free" );
  echo form_checkbox("charg",TRUE);
?>

How can i checked my radiobutton when fetching data from database?
#2

[eluser]ghst[/eluser]
If i understood you right it could be like that:

Code:
$checkbox_array = array('name' => 'charges', 'value' => 'free', 'checked' => $charg['checked']);

echo form_radio($checkbox_array);

Form helper functions can be found here
http://ellislab.com/codeigniter/user-gui...elper.html
#3

[eluser]Rocky Mehta[/eluser]
Still not Working.
To this this code i checked my checkbox(fetching the data from database)
Code:
if($query['bring']=='1')  // This code working.
  {
    $data['bring']['checked'] = TRUE;
  }
  else
  {
   $data['bring']['checked'] = FALSE;
  }
But How can i checked my radiobutton(fetch data from database)
Code:
if($query['charges']=='free')       //This code not checked my radio button.
{
   $data['charges']['checked'] = TRUE;
   echo set_radio('charges', 'free', TRUE);
}
else
{
   ....
}




Theme © iAndrew 2016 - Forum software by © MyBB