如何通过弹出菜单中的选定选项更改进行设置?

时间:2016-09-05 13:54:05

标签: javascript jquery html css

我有以下选择:

<form>
<select id="poSelect" >
<option selected disabled>Choose here</option>
<option id="buyeroption" value="100101">I am a Buyer</option>                                                                           
<option id="garageoption" value="100102">I am a Garage</option>                                                                           
</select>

<label>Full Name</label>
<input type="text" />

<label>Email Address</label>
<input type="email" />

<label>Password</label>
<input type="password" />

<label id="industrylabel" >Select Your Brand</label>
<select id="industryoption">
<option selected disabled>Select</option>   
<option value="Renault">Renault</option>
<option value="Pegaut">Pegaut</option>
<option value="Citroen">Citroen</option>
</select>

<div class="form-check-label">
<input id="send_updates" type="checkbox" />
<label for="send_updates">Send me occasional email updates</label>
 </div> 

所以我需要的是当用户选择我是买家标签时“选择你的品牌”和行业选项选择隐藏但是当我点击我是车库出现时。

1 个答案:

答案 0 :(得分:0)

<form>
<select id="mySelect">
<option id="apple">Apple</option>
<option id="orange">Orange</option>
<option id="pineapple">Pineapple</option>
<option id="banana">Banana</option>
</select>
</form>
<p></p>

<button onclick="myFunction()">textbox1</button>
<p id="demo"></p> 
<script>
function myFunction() {
var x = document.getElementById("mySelect").options.namedItem("banana").text;
document.getElementById("demo").innerHTML = x;
 }
 </script>

如果你想改变任何东西,也许你想要这样的东西请查看以下链接: - http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_select_options6