Solved

form_dropdown() in codeigniter

Posted on 2013-01-27
2
1,669 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

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…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

751 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