• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

Cannot disable select list

This code works great for disabling a select box when anything is typed into a particular input box. But I cannot get this code to work when applying it to my project.

I have included two sets of code:  "THE CODE THAT WORKS"  and  "THE CODE APPLIED TO MY PROJECT."

Can you tell me if I have applied this to my code correctly?

"THE CODE THAT WORKS"
<html>
<head>
<title>Untitled Document</title>
<script language="javascript">
      function test(oTxt, oSel) {
         if(oTxt.value.length >= 1)
         oSel.disabled = true;
         else
         oSel.disabled = false;
      }      
</script>
</head>
<body>
      <select name="selTechnicalName">
         <option value="1">1</option>
         <option value="2">2</option>
      </select>
      &nbsp;
               <input type="text" name="txtOther" style="width:150px" onKeyUp="javascript:test(this, selTechnicalName);"/>
</body>
</html>

"THE CODE APPLIED TO MY PROJECT"
I tried to paste only the code that seemed relavant. The main thing I want to know, is if I have any errors in the below code.

The bottom of the code has been cut off, because the only thing I am having trouble with is this function. I have proved that the onKeyUp event is working. I used an alert, to ensure that that the funtion is being called; but the funnction is not disabling my select list. Once again, as with everything I try -- nothing happens...


<html>
<head>
<script type="text/javascript">

function test(oTxt, oSel) {
   if(oTxt.value.length >= 1)
   oSel.disabled = true;
   else
   oSel.disabled = false;
}
}

</script>
</head>
<body>
<table border="1" cellpadding="0" cellspacing="1">

<tr>
<td  class="HeaderRidgeBottom" colspan="3" style="font-size: 12px;">Tools Portal -- Application Documentation Screen</td>
<td><input type="hidden" name="txtID_FLD" ID=Text1/></td>
</tr>              
<tr>
<td>Technical name:</td>
<td colspan="2"><select name="txtTechName" class="clsInputTextTab3_50" type="text"  ID="txtTechName"/><option value=""></option>
    <%
    Do Until oRstADW_COL.EOF
      Response.Write("<option value='" & oRstADW_COL.Fields("mdo_nm") & "'>" & oRstADW_COL.Fields("mdo_nm") & "</option>")
   oRstADW_COL.MoveNext
   Loop
  %>
</select>
&nbsp;Other:&nbsp;<input name="txtTechNameOther" class="clsInputTextTab3_50" type="text"  ID="txtTechNameOther" onKeyUp="javascript:test(this, txtTechName);"  /></td></tr>
0
JA67
Asked:
JA67
  • 2
  • 2
1 Solution
 
bobbit31Commented:
<input name="txtTechNameOther" class="clsInputTextTab3_50" type="text"  ID="txtTechNameOther" onKeyUp="test(this, this.form.txtTechName);"  />
0
 
JA67Author Commented:

Thanks for the quick response. It still does not work after making the change you denoted. I get, "Error on page" at the bottom on the browser when I type into the input box.

I successfuly call functions elsewhere in my code with the format of:  onClick="javascript:addValuesFLDS();"  

Have any other ideas?

Thank you!

JA67
0
 
bobbit31Commented:
you also have an extra closing } (dunno if it was a typo):

<script type="text/javascript">

function test(oTxt, oSel) {
   if(oTxt.value.length >= 1)
   oSel.disabled = true;
   else
   oSel.disabled = false;
}
} <--- HERE

</script>

and you did notice i changed txtTechName to this.form.txtTechName as the second parameter to test right?
0
 
JA67Author Commented:

Man you folks are smart! This is the best money I have ever spent!  It was the extra curly bracket that was causing the problem. Man -- I feel like I'm just too stupid to do this stuff.  And yes, I noticed the "this.form.txtTechName" and I tried it, but it was ultimately the extra closing bracket that you pointed out. It works now with it being exactly as I posted it, minus the extra closing bracket!

THANK YOU!!!!!!!

JA67
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now