2013-10-01 42 views
1

在選擇問題類型的基礎上,我想顯示第二個下拉列表。如果有人選擇董事會我想顯示第二下拉,如果有人選擇品牌我想顯示不同的選項。請幫助如何更改jquery下拉值

<label for="Issue Type">Issue Type</label> 
      <select name="issue_type" id="issue_type"> 
       <option value=""> Select </option> 
       <option value="Board">Board</option> 
       <option value="Branding/Clipon">Branding/Clipon</option> 
      </select> 

<label for="Issue Type">Issue</label> 
      <select name="send_to" id="send_to"> 
       <option value=""> Select </option> 
       <option value="Light Not Working">Light Not Working</option> 
       <option value="Broken Letter">Broken Letter</option> 
       <option value="Transit of Board from One address to Another">Transit of Board from One address to Another</option> 
       <option value="Broken Board">Broken Board</option> 
      </select> 
      <select name="send_to" id="send_to"> 
       <option value=""> Select </option> 
       <option value="Pasting Problem">Pasting Problem</option> 
       <option value="Clip-on light not working">Clip-on light not working</option> 
      </select> 
+0

哪裏是你的javascript代碼..? –

+0

我不知道...我很新這個... –

回答

1

在你select

<select name="issue_type" id="issue_type" onchange="change('issue_type');"> 

在你的js文件

$(document).ready(function(){ 
    function change(id) { 
     //check condition if as 
     if ($('#' + id).val() == 'Board') { 
      //hide select except your required select 
      //like 
      $("#send_to").show().siblings().hide(); 
     } else if() { // your next condition 
      //so on 
     } 
    } 
}); 
+0

我喜歡這種方法比我自己:) – Kuro

0

這裏是jQuery的

和輕微修改您的HTML

<label for="Issue Type">Issue Type</label> 
     <select name="issue_type" id="issue_type"> 
      <option value=""> Select </option> 
      <option value="Board">Board</option> 
      <option value="Branding/Clipon">Branding/Clipon</option> 
     </select> 

<label for="Issue Type">Issue</label> 
     <select name="send_to" id="send_to"> 
      <option value=""> Select </option> 
      <option value="Light Not Working">Light Not Working</option> 
      <option value="Broken Letter">Broken Letter</option> 
      <option value="Transit of Board from One address to Another">Transit of Board from One address to Another</option> 
      <option value="Broken Board">Broken Board</option> 
     </select> 
     <select name="send_to" id="send_to_board"> 
      <option value=""> Select </option> 
      <option value="Pasting Problem">Pasting Problem</option> 
      <option value="Clip-on light not working">Clip-on light not working</option> 
     </select> 

我改變的第二的ID選擇

CSS:

.hidden{display:none} 

這裏的工作的jsfiddle:http://jsfiddle.net/MXjmY/1/

+0

謝謝kuro ...我相信它會解決我的概率。 m工作和iwll更新你,謝謝你的gr8幫助夥伴 –