Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts
Codeigniter Tutorial 2: How do i get the select tag value with codeigniter?
How to get a selected option value in your controller in codeigniter Here are steps
company.php in view
<form action="" method="POST">
<select name="company" class="form control">
<option value="1">Employee </option>
<option value="2">HR</option>
<option value="3">Student</option>
</select>
<input type="submit" name="submit" value="Post it">
</form>
or Display from database field list
$cmp_values = $this->db->query("SELECT * from company");
<select name="company" aria-controls="example1" class="form-control" required>
<option value="">Select</option>
<?php foreach($cmp_values->result_array() as $cmpdet){?>
<option value="<?=$cmpdet['com_id']?>"><?=$cmpdet['com_value']?></option>
<?php }?>
</select>
<select name="company" aria-controls="example1" class="form-control" required>
<option value="">Select</option>
<?php foreach($cmp_values->result_array() as $cmpdet){?>
<option value="<?=$cmpdet['com_id']?>"><?=$cmpdet['com_value']?></option>
<?php }?>
</select>
Then in your controller:
Company.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Company extends CI_Controller {
public function index() {
if( $this->input->post) {
echo $this->input->post('company');
}
$this->load->view('company');
}
}
class Company extends CI_Controller {
public function index() {
if( $this->input->post) {
echo $this->input->post('company');
}
$this->load->view('company');
}
}
Subscribe to:
Posts (Atom)
Popular Posts
-
You already have to WordPress website to set up the Contact form and details will directly into your mail account. 1. click...
-
In Laravel Let's go with the example using controller name is Product 1. Create controller in Controllers case sensitive name so, cr...
-
How to call ajax with php its easy step to call ajax lets we go for more we need to pass a url in ajax to call php function/variable/data f...
-
how to form submit on timer/countdown you can pass time through in javascript CountDown(5,div); function, example 10 second pass CountDown(...
-
Get the value of the using the id, define the route of the laravel with id, looking for passing to route to controller as per following. ...
-
In the Linux most useful commands makes you more easy to manage files system. Let's learn most known Linux commands. 1) Listing fil...
-
Laravel setup in localhost before we need basic requirement to fulfill laravel works, you will need to make sure your server meets the foll...
-
Skype chat integration to the website its very easy and get more customer and relationship with your client.
-
Add a rich text editor/tinymce editor in activity stream instead of the actual textarea (id= #wats-new-textarea”) copy the file with the ...
-
Adding an existing project to GitHub using the command line, Putting your existing work project on GitHub can let you share and collaborate...