This topic is locked

Checking for textbox contents

3/4/2009 10:59:49 PM
ASPRunnerPro General questions
A
agruspe author

I have the following fields
category

subcategory

description
I would like to disable/enable edit to the description field if a certain word is found on the subcategory field. The category field is a drop-down and subcategory is a dependent drop-down. The description field is a memo field.
I used the following code but is does not work.

<script>

document.forms.editform.value_subcategory.onchange=function()

{

if(InStr(document.forms.editform.value_subcategory.value,"On-Site")

{

document.forms.editform.value_description.disabled=true;

}

else

{

document.forms.editform.value_description.disabled=false;

}

}

</SCRIPT>
J
Jane 3/5/2009

Hi,
use JavaScript functions in your code, not VBScript.

For example indexOf() function:

http://www.w3schools.com/jsref/jsref_indexOf.asp

A
agruspe author 3/5/2009

Hi Jane,
Thanks a lot for the info... It is now working.
To other users, the code I used is below:

<script>

document.forms.editform.value_subcategory.onchange=function()

{

var str_subcat = document.forms.editform.value_subcategory.value

if(str_subcat.indexOf("On-Site")>0)

{

document.forms.editform.value_description.disabled=true;

}

else

{

document.forms.editform.value_description.disabled=false;

}

}

</SCRIPT>