Hi,

I have a problem in the below requirement.

Marital Status (Select-one) SpouseName ( Textbox )
(Single)
(Married)

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.

Recommended Answers

All 6 Replies

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.

Member Avatar for rajarajan2017
<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()
{
document.form1.address2.disabled=false;
}
 
</script>

<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.

commented: Do not post homework problems expecting a quick answer without showing any effort yourself. Read forum rules. -1

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.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.