如何根据另一个组合重新加载一个组合框。

时间:2014-10-10 18:04:38

标签: javascript php jquery html

我想根据选择或第一个组合框重新加载第二个组合框。这是一个原生的javascript / jquery / php网站。

如何在template_owner组合框中进行选择后重新加载template_id组合框?

<tr>
   <td id="BaseFont" width="5%" nowrap>Person: </td>
   <TD id="BaseFont" nowrap>
      <SELECT name="template_owner" onchange="SetTemplate();">                                                                
      <?                    
         $query  = "SELECT distinct ud.people_id, concat(ud.first_name, ' ',ud.last_name)  as people_name ";
         $query .= "from job_detail jd, ";
         $query .= "user_detail ud ";
         $query .= "where job_type='T' ";
         $query .= "and jd.people_id = ud.people_id ";
         $query .= "order by ud.first_name, ud.last_name";

         $cnt_temp = query_exec($query,$temp_arr);
         for($t=0;$t<$cnt_temp;$t++){
             print("<option value=\"" . $temp_arr[$t][0] . '" ' . ($template_owner_id == $temp_arr[$t][0] ? "selected" : "") .">" . $temp_arr[$t][1] ."</option>");        
         }
      ?>                                            
    </SELECT>
  </TD>
</tr>   

<tr>                                  
    <td id="BaseFont" width="5%" nowrap>Template: </td>
    <td id="BaseFont" nowrap>
      <select name="template_id" onchange="if(this.value)this.form.job_name.value=this.options[this.selectedIndex].text;">
    <option value=""> --- Select one ---
      <?  
    if($from_job_type=='M'){
       $query = "SELECT job_id,job_name from job_detail where job_type='$from_job_type' order by upper(job_name)";
    }else{
           $query = "SELECT job_id,job_name from job_detail where job_type='T' and people_id=$template_owner_id order by upper(job_name)";
    }

        $cnt_temp = query_exec($query,$temp_arr);
    for($t=0;$t<$cnt_temp;$t++){
       print("<option value=\"".$temp_arr[$t][0]."\">".$temp_arr[$t][1]."\n");  
        }
      ?>
      </select>
   </td>
</tr>

0 个答案:

没有答案