Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

form_dropdown() in codeigniter

Posted on 2013-01-27
2
Medium Priority
?
1,757 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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 …

715 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