Javascript:根据特定下拉列表的值隐藏表单输入 [英] Javascript: hide a form input depending on the value of a particular drop-down

查看:135
本文介绍了Javascript:根据特定下拉列表的值隐藏表单输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我想根据下拉菜单中选定的值隐藏输入选项。具体来说,如果选择的值是tid和acc,我只是显示此输入标签。

Basically, I want to hide an input option depending based on the selected value of a drop-down menu. Specifically, I only what to show this input tag if the value selected is tid and acc.

我有这个下拉菜单。

<select id="select1742855Rule Type" onchange="document.getElementById('form1742855_Rule Type').value=this.value;">
        <option value="" selected="selected">None</option>
        <option value="tid">tid</option>
        <option value="tid and acc">tid and acc</option>
        <option value="xid">xid</option>
 </select>

此输入标签:

<input type="text" size="6" id = "acc" onchange="document.getElementById('form1742851_Id').value=this.value;">

我是一个完美的新手,当谈到javascript。任何帮助将不胜感激!

I am a utter novice when it comes to javascript. Any help will be much appreciated!

推荐答案

首先:在控件中不要使用空格 id

First of all: do no use white space in controls id

$('#select1742855Rule_Type').change(function() {
   var val = $(this).val();
   if (val == 'tid and acc') {
      $('#acc').show();
   }
   else {
      $('#acc').hide(); 
   }
});

这篇关于Javascript:根据特定下拉列表的值隐藏表单输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆