Solved

Conditional Enabling/Disabling Textbox using dropdown and visa/versa

Posted on 2011-02-23
6
676 Views
Last Modified: 2012-05-11
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....
0
Comment
Question by:khasm1972
6 Comments
 
LVL 9

Expert Comment

by:rawinnlnx9
ID: 34961939
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.
0
 
LVL 9

Expert Comment

by:rawinnlnx9
ID: 34961948
Now all you should replace is the .DropLineItem. with .{NEWNAME}. and the same for the other control.
0
 

Author Comment

by:khasm1972
ID: 34962067
The control names look the same to me when I view the page source.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 40

Accepted Solution

by:
gurvinder372 earned 250 total points
ID: 34962184
replace it with

<script LANGUAGE="javascript">
    function Toggle_AcctNumber(){
     
      if(document.getElementById("DropLineItem").value != "NOI")
        document.getElementById("AcctNumber").disabled="true";
     
      else if(document.getElementById("AcctNumber").value.length != 0)
              document.getElementById("DropLineItem").disabled=true;
    }
  </script>
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34962237
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

0
 

Author Comment

by:khasm1972
ID: 34962282
ok...i still have some kinks to run out of it but at least it is working now.....
thanks gurvinder372....
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JS does not refresh 6 30
how can i get the string decoded ? 2 28
jquery tab header text 1 22
Autocomplete with Jquery Question 2 19
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question