Khari Buchanan
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.DropL ineItem.va lue != [NOI])
document.GetParms.AcctNumb er".disabl ed="true";
else if(document.Getparms.AcctN umber.valu e.length != 0)
document.GetParms.DropLine Item.disab led=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....
<script LANGUAGE="javascript">
function Toggle_AcctNumber(){
if(document.Getparms.DropL
document.GetParms.AcctNumb
else if(document.Getparms.AcctN
document.GetParms.DropLine
}
</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....
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.
ASKER
The control names look the same to me when I view the page source.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think rawinnlnx9 is confusing ASP with ASP.Net.
The following works for me, try comparing it with what you have:
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>
ASKER
ok...i still have some kinks to run out of it but at least it is working now.....
thanks gurvinder372....
thanks gurvinder372....