how to do second dropdown based on selection of first dropdown using script and PHP/MySQL

Permalink 1 user found helpful
my single page code:

<form method="post" action="<?php echo $this->action('save_task') ?>">
            <table class="row-fluid">
                  <td><label for="taProj"><?php echo t('Project')?>:</label></td>
                  <td><select name="taProj" id="taProj" onchange= "get_module()">
                     <option value="" >-------------------------</option>
                     <?php   foreach ($tap as $row){?>               
                     <option value="<?php echo $row['proj_id']; ?>" ><?php echo $row['proj_name'];?></option>
                     <?php } ?>
                  <td><label for="taModule"><?php echo t('Module Name')?>:</label></td>
                  <td><select name="taModule" id="taModule" >
                     <option value="" >-------------------------</option>

controller code:
Class TaskAllocationAddTaskController extends Controller {
   public function on_start() {
      $html = Loader::helper('html');
      $tap = projectinfo::get_proj();   
      $this->set('tap', $tap);      
      $tam = moduleinfo::get_module();

Now i want to pass the projid value from single then load the option in the module 'taModule' dropdown

View Replies:
shankumars replied on at Permalink Reply
Hi I got some idea from google by using ajax. but i dont know its right or wrong

url: '<?php echo $this->action('sample'); ?>',
data: {variable: value}

any one suggest the right way....
ronyDdeveloper replied on at Permalink Reply
shankumars replied on at Permalink Reply
This is already john suggest to me... but i cant understand the add-on code... that why i ask again to you... will you suggest me any other easy way or link to understand to my knowledge