select与option:实现表单对应显示和对应显隐

一、表单对应显示

部分效果图:

代码实现:定义方法,通过if判断语句分项显示
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
     <title>表单对应显示</title>
     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
     <script type="text/javascript" language="javascript">
         $(function(){
             
             $("#dropLang").unbind("change", eDropLangChange).bind("change", eDropLangChange);
             $("#dropFrame").unbind("change", eDropFrameChange).bind("change", eDropFrameChange);
         });
    
         
         var eDropLangChange = function(){
         
             var selectedValue = $(this).val();
            

            $("#dropFrame").children("span").each(function(){
                $(this).children().clone().replaceAll($(this));         
            });
            
           
            if(parseInt(selectedValue) != 0){       
                 
                $("#dropFrame").children("option[parentid!='" + selectedValue + "'][value!='0']").each(function(){
                     $(this).wrap("<span style='display:none'></span>");
                });
             }
       };
        
         
        var eDropFrameChange = function(){
             
             $("#dropLang").val($(this).children("option:selected").attr("parentid"));
         };
     </script>
 </head>
 <body>
     <div>
         <select id="dropLang">
            <option selected="selected" value="0">&lt;请选择&gt;</option>
             <option value="1">Javascript</option>
             <option value="2">Java</option>
             <option value="3">C#</option>
         </select>
         <select id="dropFrame">
             <option selected="selected" value="0">&lt;请选择&gt;</option>
             <option value="1" parentid="1">JQuery</option>
             <option value="2" parentid="1">Prototype</option>
             <option value="3" parentid="2">Struts</option>
             <option value="4" parentid="2">Spring</option>
             <option value="5" parentid="2">Velocity</option>
             <option value="6" parentid="2">Hibernate</option>
             <option value="7" parentid="3">ASP.NET MVC</option>
             <option value="8" parentid="3">Castle</option>
        </select>
    </div>
</body>
</html>

二、表单对应显隐

部分效果图:

代码实现:定义对应获取id,判断value值,再显隐
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="majianan">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
<script>
var sname = [];
sname.push('s1');
sname.push('s2');
sname.push('s3');
sname.push('s4');
function setselect(obj){
    var flag = false;
    for(var i=0;i<sname.length;i++){
        if(sname[i]==obj){
            if(document.getElementById(sname[i]).value==3 || document.getElementById(sname[i]).value==4){
                flag = true;
            }            
        }else{
            continue;
        }
    }

    if(flag){
        for(var i=0;i<sname.length;i++){
            if(sname[i]==obj) continue;
            else{
                document.getElementById(sname[i]).disabled = true;
            }
        }
    }else{
        for(var i=0;i<sname.length;i++){
            document.getElementById(sname[i]).disabled = false;
        }
    }
}
</script>
 </HEAD>

 <BODY>
  <SELECT id='s1' onChange="setselect(this.id);">
    <option value='1'>自考</option>
    <option value='2'>成考</option>
    <option value='3'>四级英语</option>
    <option value='4'>计算机等级</option>
  </SELECT>
  <SELECT id='s2' onChange="setselect(this.id);">
    <option value='1'>op1</option>
    <option value='2'>op2</option>
    <option value='3'>op3</option>
    <option value='4'>op4</option>
  </SELECT>
    <SELECT id='s3' onChange="setselect(this.id);">
    <option value='1'>op1</option>
    <option value='2'>op2</option>
    <option value='3'>op3</option>
    <option value='4'>op4</option>
  </SELECT>
    <SELECT id='s4' onChange="setselect(this.id);">
    <option value='1'>op1</option>
    <option value='2'>op2</option>
    <option value='3'>op3</option>
    <option value='4'>op4</option>
  </SELECT>
 </BODY>
</HTML>



<u-modal :ref="`senPi`" :size="`huge`" :is-heading-slot-empty="true"> <template #title> <u-text :text="`报价详情`"></u-text> </template> <template #body> <u-linear-layout direction="vertical" wrap> <u-form :layout="`inline`" key="form_13"> <u-form-item :layout="`center`"> <template #label> <u-text :text="`供应商id`"></u-text> </template> <u-select :clearable="true" :placeholder="`请选择供应商id`" :dataSource="__select_20_handleDataSourceLoad()" :pageSize="50" :textField="`supplier.name`" :valueField="`supplier.name`" :pagination="true" :value.sync="filter2.supplierId" :emptyValueIsNull="true" key="select_20" > <template #option="current"></template> <template #renderFooter></template> </u-select> </u-form-item> <u-form-item :layout="`center`"> <template #label> <u-text :text="`最终供应商`"></u-text> </template> <u-select :clearable="true" :value.sync="filter2.finalSupplier" :placeholder="`请选择最终供应商`" :dataSource="$utils['EnumToList']({ concept: 'TypeAnnotation', typeKind: 'reference', typeNamespace: 'app.enums', typeName: 'Is_Final_Supplier', inferred: false, ruleMap: {}, typeArguments: [] })" :emptyValueIsNull="true" key="select_22" > <template #option="current"></template> <template #renderFooter></template> </u-select> </u-form-item> <u-form-item :layout="`center`" :labelSize="`auto`"> <u-button :color="`primary`" :text="`查 询`" @click="onQueryClick($event)"></u-button> </u-form-item> </u-form> <!-- 树形表格,支持折叠子表 --> <el-table :data="treeData" row-key="id" :tree-props="{ children: 'quotedPrices', hasChildren: 'hasChildren' }" border style="--cw-style-font-size: 10px; font-size: 10px; --table-view-th-padding: 1px; --table-view-td-padding: 1px; --table-cell-padding: 0px" > <!-- 展开列 --> <el-table-column type="expand" label="展开" width="50" :expandable="(row) => Array.isArray(row.quotedPrices) && row.quotedPrices.length > 0" :expanded="(row) => row.isExpanded" @expand-change="handleExpandChange" ></el-table-column> <el-table-column prop="materialApplyId" label="物料申请单id" width="150"></el-table-column> <el-table-column prop="supplierId" label="供应商id" width="150"></el-table-column> <el-table-column prop="finalSupplier" label="最终供应商" width="150"></el-table-column> <!-- 子表格:报价详情 --> <el-table-column label="报价详情" width="300"> <template #default="scope"> <el-table v-if="Array.isArray(scope.row.quotedPrices) && scope.row.quotedPrices.length > 0" :data="scope.row.quotedPrices" style="width: 100%; font-size: 10px;" border > <el-table-column prop="times" label="报价次数" width="100"></el-table-column> <el-table-column prop="price" label="报价价格" width="100"></el-table-column> <el-table-column prop="lastPrice" label="是否最终报价" width="100"></el-table-column> </el-table> </template> </el-table-column> </el-table> </u-linear-layout> </template> </u-modal>
03-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值