Solved

form_dropdown() in codeigniter

Posted on 2013-01-27
2
1,621 Views
Last Modified: 2013-01-28
Hi, I am a complete novice to codeigniter and  have no idea how to handle this

I have a query in my controller:

 
  	// dropdown list  
		  $this->data['main_level'] = $this->menu->main_level();
		  $this->load->view('menu',$this->data);

Open in new window


  in my view I am definining a form:
 <?php echo form_open(); ?>

<table class="table">
	<tr>
		<td>Parent</td>
			<td><?php echo form_dropdown('parent_id', $main_level, ' '); ?> </td>
	</tr>
	
</table>


<?php echo form_close();?>

Open in new window


now, upon selection I want to run another query and display the result under the dropdown ?. How to do it ?
Also can I have blank in the third parameter for the dropdown indicating that upon loading
nothing was selected ?
  $this->data['main_level'] = $this->menu_model->main_level();

Open in new window

0
Comment
Question by:sniger
2 Comments
 
LVL 11

Accepted Solution

by:
mcnute earned 500 total points
ID: 38826239
Ajax is your way to do it. Jquery implement very good ajax methods.

In your ajax request you specify the controller which sends back the list options based on a parameter you gaven in the ajax call like so:

$.ajax({
									url: 'your/controller',
									data: 'option=1',
									success: function(data) {
										//insert the results in the sepcified select list.
									}
								});

Open in new window

0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 38826301
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question