Conditional Enabling/Disabling Textbox using dropdown and visa/versa

I've reached an impasse and need some help to make it over this hump. I'm working on an asp page that will have conditional validating of a textbox and a dropdown list. I created a function that looks like this:

<script LANGUAGE="javascript">
    function Toggle_AcctNumber(){
      if(document.Getparms.DropLineItem.value != [NOI])
      else if(document.Getparms.AcctNumber.value.length != 0)

and here is how i call that function in the dropdown and textbox....

 <SELECT name="DropLineItem" id=DropLineItem onclick = "Toggle_AcctNumber();" size="1" style="HEIGHT: 22px; WIDTH: 320px">

<input type="text" id="AcctNumber" name="AcctNumber" onchange = "Toggle_AcctNumber();">

can anyone tell me what i'm doing wrong? Thanks....
Who is Participating?
Gurvinder Pal SinghConnect With a Mentor Commented:
replace it with

<script LANGUAGE="javascript">
    function Toggle_AcctNumber(){
      if(document.getElementById("DropLineItem").value != "NOI")
      else if(document.getElementById("AcctNumber").value.length != 0)
Yes, you need to view your page source. ASP prefixes additional text to all web controls at render/run time. So view source, get the name that ASP generated and replace .DropLineItem.Disabled with the full name you found in the rendered HTML. Do this for both of your document.GetParms calls and you should be back on track.
Now all you should replace is the .DropLineItem. with .{NEWNAME}. and the same for the other control.
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

khasm1972Author Commented:
The control names look the same to me when I view the page source.
Carl TawnSystems and Integration DeveloperCommented:
I think rawinnlnx9 is confusing ASP with ASP.Net.

The following works for me, try comparing it with what you have:
   <script type="text/javascript">
     function Toggle_AcctNumber()
        if (document.GetParms.DropLineItem.value != 'NOI')
          document.GetParms.AcctNumber.disabled = true;
        else if (document.GetParms.AcctNumber.value.length != 0)
          document.GetParms.DropLineItem.disabled = true;

    <form name="GetParms" id="GetParms">
      <select name="DropLineItem" id="DropLineItem" onclick="Toggle_AcctNumber();">
         <option value="NOI">NOI</option>
         <option value="One">One</option>

      <input type="text" id="AcctNumber" name="AcctNumber" onchange="Toggle_AcctNumber();" />


Open in new window

khasm1972Author Commented:
ok...i still have some kinks to run out of it but at least it is working now.....
thanks gurvinder372....
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.