Link to home
Start Free TrialLog in
Avatar of Khari Buchanan
Khari BuchananFlag for United States of America

asked on

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])
        document.GetParms.AcctNumber".disabled="true";
     
      else if(document.Getparms.AcctNumber.value.length != 0)
              document.GetParms.DropLineItem.disabled=true;
    }
  </script>

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....
Avatar of rawinnlnx9
rawinnlnx9
Flag of United States of America image

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.
Avatar of Khari Buchanan

ASKER

The control names look the same to me when I view the page source.
ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think rawinnlnx9 is confusing ASP with ASP.Net.

The following works for me, try comparing it with what you have:
<html>
<head>
   <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;
     }
   </script>
</head>
<body>


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

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

</body>
</html>

Open in new window

ok...i still have some kinks to run out of it but at least it is working now.....
thanks gurvinder372....