I have a problem in the below requirement.

Marital Status (Select-one) SpouseName ( Textbox )

Whenever i choose an option married only then spouseName is activated( Mouse Cursor is enabled) other wise in rest of the cases it should be in read-only property.

Please help me the code.

8 Years
Discussion Span
Last Post by jt86442

First off you will want to set your text box to disabled. Then you will need to attach an on change event on your select element. The function that handles the on change will need to check the selected index in the select box and then remove the disabled property from the text box.

<input type="text" name="text1" id="txt1" value="Text 1" [B]disabled [/B]>

The above is too disable the textbox

Sample code to control text box dynamically

<script language="javascript">

function enableField()

<a href="javascript:enableField()">Click here to enable the element<a/>

Please help me the code.

Please do your own code, not come here to ask for code. The forum is to help you fix your code, not to do your own homework...

By the way, the 'read only' means 'disable' or really means 'read only'. There are two different things. 'read only' means no user can make changes but the value of the element is still passed via form. 'disable' on the other hand, will not be passed via form.


I came to understand that you are unable to write a code for my thread. ok anyway, Am i mentioned anywhere "disabled" term in my thread. I clearly specified that it was "read-only" mode. First try to understand the thread after u can do my homework.

Votes + Comments
Do not post homework problems expecting a quick answer without showing any effort yourself. Read forum rules.

First try to understand the thread after u can do my homework.

I understood what 'readonly' means, but I do not do your homework. Also, if you accept Raja's solution, it means you confuse yourself with the meaning of 'readonly'. His solution is using 'disable' which is NOT 'readonly'. I just clarified the meaning of both words and hope you would get it in order to do your own homework correctly.


This statement you have to give previously in the properway that was if i taken raja solution. Anyway thanks for your suggetion. i click on solved.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.