Solved

form_dropdown() in codeigniter

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now