?
Solved

Conditional Enabling/Disabling Textbox using dropdown and visa/versa

Posted on 2011-02-23
6
Medium Priority
?
679 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 40

Accepted Solution

by:
Gurvinder Pal Singh earned 1000 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…
Suggested Courses

777 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