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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to disable textbox

Status
Not open for further replies.

peteswrx

Programmer
Sep 16, 2002
12
US
I have a combobox that looks like this:
<select name = &quot;cboList&quot;>
<option>Not in list</option>
<option>Vendor1</option>
<option>Vendor2</option>
<option>Vendor3</option
</select>

I also have another textbox that looks like this:
<INPUT type=&quot;text&quot; name=&quot;txtVendorName&quot;>

I want to disable the textbox whenever the combobox does not = &quot;Not in List&quot;.

This doesn't seem too difficult but it's giving me plenty of headaches...

Much thanks goes out to anyone who can assist here.
 
peteswrx,

<input type=&quot;text&quot; name=&quot;mytext&quot; onFocus=&quot;this.blur()&quot;>


fengshui_1998
 
<select name = &quot;cboList&quot; onChange=&quot;CheckOption()>
<option>Not in list</option>
<option>Vendor1</option>
<option>Vendor2</option>
<option>Vendor3</option
</select>


function CheckOption()
{

if cboList.options{cboList.selectedIndex).text==&quot;Not In List&quot;
then mytext.disabled = true
else
mytext.disabled=false
end if

}
just tweak this a bit
 
Thanks I figured it out. This seems to work pretty good...

<script language = &quot;vbscript&quot;>
sub DisableTextbox()
if document.Vendor.cboVendor.value <> &quot;&quot; then
document.Vendor.txtVendorName.value=&quot;&quot;
document.Vendor.txtVendorName.disabled=true
else
document.Vendor.txtVendorName.disabled=false
end if
end sub
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top