Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Drop-down and Display DIV function, only 1/2 works

Status
Not open for further replies.

jojo79

Programmer
Oct 11, 2006
40
US
I am trying to display a DIV and disable a drop down box at the same time with a check-box. The code I have works perfect except when I unchecked the check-box, The drop down still stays disabled. I mean the DIV disappears fine but the drop down stays disabled. Anyone have a clue why?????

Form Name: OrderEntry
Dropdown Name: Consignee
Checkbox Name: chkcng

The dropdown is not inside of the DIV, It is directly above it. What i am tryign to do is, The dropdown is a list of customers, When the order is for a 1 time only customer, i was to disable the dropdown and display that div. everything works fine until i unckeck the checkbox.

Code:
function hidedivcng() { 
if (document.all.chkcng.checked) { // DOM3 = IE5, NS6 
document.all.txtbol.style.display = 'inline';
document.OrderEntry.Consignee.disabled="true"
} 

else { 
document.all.txtbol.style.display = 'none';
document.OrderEntry.Consignee.disabled="false" 
}
}
 
Dunno, looks like it should work. Maybe try getting rid of the document.all out of your code. I can tell you right now that your code won't work in Firefox at all.


-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Got it to Work, All I did was remove the "

Anybody know why????

Code:
function hidedivcng() { 
if (document.all.chkcng.checked) { 
document.all.txtbol.style.display = 'inline';
document.OrderEntry.Consignee.disabled=true
} 

else { 
document.all.txtbol.style.display = 'none';
document.OrderEntry.Consignee.disabled=false 
}
}
 
Probably because "true" is a string, not a boolean value, and isn't being converted to a proper boolean value. Actually, it is the "false" that isn't being converted properly. Any non-empty string will evaluate to true in a boolean context. So even though you coded "false" the value getting assigned is true.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top