Solved

form_dropdown() in codeigniter

Posted on 2013-01-27
2
1,632 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

840 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