Wade Wade - 1 year ago 60
Javascript Question

My first option value does not display my hidden div

I have onchange select event, my problem is the first value of select option value was not load the javascript until I select it into other value and back to first value. How I can trigger to load my script when I load it.

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>

Answer Source
    var value = this.value; if (value != "SHOPPING" && value !='NEGOTIATED'){ 
    $("#OtherDiv").css("display","none"); }   
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download