0

我有 onchange 选择事件,我的问题是选择选项值的第一个值没有加载 javascript,直到我将其选择为其他值并返回第一个值。加载脚本时如何触发加载脚本。

function test(){
        showOther = function(val){
            if(val && val !='SHOPPING' && val !='NEGOTIATED'){
                document.getElementById('OtherDiv').style.display = '';
            } else {
                document.getElementById('OtherDiv').style.display = 'none';
                    }
                }
            }
            window.onload = test;

<select id="txt10" onchange="showOther(this.value);" class="textbox1" tabindex="6" style="width:150px;height:23px;">
        <option value="<?php echo $mod; ?>" style="text-transform:uppercase"><?php echo "<div style='text-transform:uppercase;color:blue;'>".$row['mode_of_procurement']."</div>"; ?></option>
        <option value="BIDDING" style="text-transform:uppercase;">BIDDING</option>
        <option value="RFQ" style="text-transform:uppercase">RFQ</option>
        <option value="NEGOTIATED" style="text-transform:uppercase">NEGOTIATED</option>
        <option value="SHOPPING" style="text-transform:uppercase">SHOPPING</option>
4

2 回答 2

0
 if(val && val !='SHOPPING' && val !='NEGOTIATED'){
            document.getElementById('OtherDiv').style.display = 'block';
        } else {
            document.getElementById('OtherDiv').style.display = 'none';
                }
            }
        }
于 2013-09-16T06:56:07.070 回答
0
    var value = this.value; if (value != "SHOPPING" && value !='NEGOTIATED'){ 
    $("#OtherDiv").css("display","block"); 
      }else{           
    $("#OtherDiv").css("display","none"); }   
于 2016-06-27T00:37:02.510 回答