阳光网驿-企业信息化交流平台【DTC零售连锁全渠道解决方案】

 找回密码
 注册

QQ登录

只需一步,快速开始

扫描二维码登录本站

手机号码,快捷登录

老司机
查看: 2152|回复: 6

[求助]html表单根据下拉选择值隐藏部分区域

[复制链接]
  • TA的每日心情
    开心
    2015-6-9 13:33
  • 签到天数: 8 天

    [LV.3]偶尔看看II

    发表于 2013-3-28 10:15:19 | 显示全部楼层 |阅读模式
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    无聊
    2016-8-31 09:59
  • 签到天数: 80 天

    [LV.6]常住居民II

    发表于 2013-3-29 13:45:23 | 显示全部楼层
    开发人员飘过。。。。这个问题很简单,自己加Q。。我远程帮你搞定
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    开心
    2014-9-4 16:34
  • 签到天数: 189 天

    [LV.7]常住居民III

    发表于 2013-4-1 20:58:20 | 显示全部楼层
    假设你的下拉选择框有2个选项,"显示","隐藏",对应的值分别就是0和1,

    设置下拉框字段的onpropertychange事件
    document.getElementById("下拉框字段Id").onpropertychange=new Function("fun1(this)");

    function fun1(){
    if(document.getElementById("下拉框字段Id").value==0)
    {
    document.getElementById("隐藏区域的Id").style.display="block";
    }

    if(document.getElementById("下拉框字段Id").value==1)
    {
    document.getElementById("隐藏区域的Id").style.display="none";

    }



    }
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    无聊
    2016-6-24 10:43
  • 签到天数: 100 天

    [LV.6]常住居民II

    发表于 2014-6-4 21:23:46 | 显示全部楼层
    非常不错,谢谢楼主分享,谢谢了
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    奋斗
    2017-7-29 13:32
  • 签到天数: 3 天

    [LV.2]偶尔看看I

    发表于 2017-7-29 13:28:32 | 显示全部楼层
    非常不错,突然觉得自己程序员出生也有不少优势的
    启用邀请码注册,提高发帖质量,建设交流社区

    该用户从未签到

    发表于 2017-8-9 14:41:49 | 显示全部楼层
    //类型字段ID,根据具体实际情况进行修改
    var type = "field10602";
    //页面加载事件
    jQuery(document).ready(function(){
    //集体/个人绑定事件
    jQuery("#"+type).bind('change',function(){
      trDisplay();
    });

    trDisplay();
    });
    //TR显隐事件
    function trDisplay(){
      var type_v = jQuery("#"+type).val();
      
      if(type_v == '0'){//价格差异导致的差额
                    jQuery("TR[ID=Main_01]").hide();
                    jQuery("TR[ID=Main_02]").hide();
       jQuery("TR[ID=TR_Group]").show();
       jQuery("TR[ID=TR_Person]").hide();
      }else if(type_v == '1') {//挑选费
                    jQuery("TR[ID=Main_01]").show();
                    jQuery("TR[ID=Main_02]").show();
       jQuery("TR[ID=TR_Group]").hide();
       jQuery("TR[ID=TR_Person]").show();
    }else if(type_v == '2') {//降价差异导致的差额
                    jQuery("TR[ID=Main_01]").hide();
                    jQuery("TR[ID=Main_02]").hide();
       jQuery("TR[ID=TR_Group]").show();
       jQuery("TR[ID=TR_Person]").hide();
    }else{
                    jQuery("TR[ID=Main_01]").hide();
                    jQuery("TR[ID=Main_02]").hide();
      jQuery("TR[ID=TR_Group]").hide();
      jQuery("TR[ID=TR_Person]").hide();
    }
    }
    启用邀请码注册,提高发帖质量,建设交流社区

    该用户从未签到

    发表于 2017-12-20 11:16:45 | 显示全部楼层
    //类型字段ID,根据具体实际情况进行修改
    var type = "field12191";

    //页面加载事件
    jQuery(document).ready(function(){
            //集体/个人绑定事件
            jQuery("#"+type).bind('change',function(){
                    trDisplay();
            });
           
            trDisplay();
    });

    //TR显隐事件
    function trDisplay(){
            var type_v = jQuery("#"+type).val();
           
            if(type_v == '0'){//价格差异导致的差额
                    jQuery("TR[ID=TR_ZL]").hide();
                    jQuery("TR[ID=TR_ZLZB]").hide();
                    jQuery("TR[ID=TR_XSZB]").show();
                    jQuery("TR[ID=TR_FZL]").show();
                    jQuery("TR[ID=TR_Group]").hide();
                    jQuery("TR[ID=TR_FJSC]").hide();
            }else if(type_v == '1') {
                    jQuery("TR[ID=TR_ZL]").show();
                    jQuery("TR[ID=TR_FZL]").hide();
                    jQuery("TR[ID=TR_Group]").show();
                    jQuery("TR[ID=TR_XSZB]").hide();
                    jQuery("TR[ID=TR_ZLZB]").show();
                    jQuery("TR[ID=TR_FJSC]").show();
            }else if(type_v == '2') {
                    jQuery("TR[ID=TR_ZL]").hide();
                    jQuery("TR[ID=TR_FZL]").show();
                    jQuery("TR[ID=TR_Group]").hide();
                    jQuery("TR[ID=TR_ZLZB]").hide();
                    jQuery("TR[ID=TR_XSZB]").show();
                    jQuery("TR[ID=TR_FJSC]").hide();
            }else{
                    jQuery("TR[ID=TR_ZL]").hide();
                    jQuery("TR[ID=TR_FZL]").hide();
                    jQuery("TR[ID=TR_Group]").hide();
                    jQuery("TR[ID=TR_ZLZB]").hide();
                    jQuery("TR[ID=TR_XSZB]").hide();
                    jQuery("TR[ID=TR_FJSC]").hide();
            }
    }


    启用邀请码注册,提高发帖质量,建设交流社区
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    快速回复 返回顶部 返回列表