Set Form Element Readonly with Javascript

How we can Set Form Element Readonly with Javascript ..

a piece of the code is here

opener.document.getElementById('jml_aset').setAttribute('readOnly','readOnly');

or the complete forum can be found here

Im affraid any lost.. Maybe copy any source code to this post is good idea...

<script type="text/javascript">

function blah(bool) {
if(bool) {
document.getElementById("ta").readOnly = true;
}
else {
document.getElementById("ta").readOnly = false;
}
}

</script>

<textarea id="ta"></textarea>
<input type="checkbox" onclick="blah(this.checked)" />


or this solution

[1] use setAttribute and removeAttribute

if(document.formOne.fieldInfo.checked)
{
document.forms['myFormId'].myTextArea.setAttribute('readOnly','readonly'); //2nd readonly more freedom
}
else //if(!document.formOne.fieldInfo.checked)
{
document.forms['myFormId'].myTextArea.removeAttribute('readOnly');
// also tried document.formOne.fieldtextarea.focus();
}

[2] property assignment

if(document.formOne.fieldInfo.checked)
{
document.forms['myFormId'].myTextArea.readOnly=true; //true has some freedom
}
else //if(!document.formOne.fieldInfo.checked)
{
document.forms['myFormId'].myTextArea.readOnly=false; //false has some freedom
// also tried document.formOne.fieldtextarea.focus();
}

Komentar FB


Probably Related Article



10 comments:

Cellular Mobile said...
January 30, 2010 at 11:43 PM

I have recently completed my professional degree in computer sciences and I want to get into web development field. I would like to ask you guys which field should I choose to develop the web application Active Server Pages (ASP.net) or PHP? I have some experience with visual studio too.

Even I have some experience with Java Mobile Applications also and have some understandings of Java libraries.

Home Loans said...
February 17, 2010 at 8:46 PM

Java is one of those languages which I like for the electronic equipments. I started learning java but later I started learning the PHP. Since there is more charm here in my country for the web development. JAVA has also the charm but I think it would take time to go for the java.

Jingles said...
February 17, 2010 at 11:39 PM

Today I have planned to give my extra time after office to go for the Java programming. I love programming and its my dream to go for the java development. Here in my country there is a huge demand for the java programmers. And I hope I can be one of those programmers in the next coming period. So I would like to say all you guys to pray for me to be successful in java.

Sex Impotence said...
February 18, 2010 at 11:16 AM

I have recently completed my first two chapters of java language, I have some introduction of Java. What is java and what is the history of Java language. Then I was given the introduction about the Java tool. I learned that there is Java Virtual Machine which is used to handle the java applications, and then the ways we can write, compile and execute the java programs. After that I learned how to write the java applications and compile them and then java applets and how to embed them in the web pages and how to execute them for a java enabled browser.

Amatory Watches said...
February 19, 2010 at 9:41 PM

I would like to add some history of JAVA.

One of the programmers from Sun was needy to develop a code for some electronic devices. When he started development using C++. He came to know that its hard to write the desired code with C++. He then write his own compiler for the sake of development. Later which was named JAVA. The first name of java was Oak.

Blog Literature said...
March 16, 2010 at 1:27 PM

Wow such a nice informative post. You have described every thing in very detailed. I 'll try to follow these practices. Thanks for sharing such a nice guiding post.

Cashier Resumes said...
December 27, 2010 at 5:26 AM

I am greatly impressed with the information and would love to practice these in future applications. Thanks for providing guidance on this subject.

Jingles said...
June 7, 2011 at 7:42 AM

I'm a novice. Does this disable all copying - regardless of browser?

Buy facebook likes said...
November 21, 2011 at 3:38 AM

You will certainly see a noticeable increase in your sales online just after you buy facebook fans from www.fanbullet.com as they sell genuine fans and likes. They provide you the prospect customers whose chances of buying your products are very high.

Web development Company said...
March 21, 2013 at 12:47 AM

I think you spend numerous effort and time updating your blog. I have bookmarked it and I am taking a look ahead to reading new articles.

Related Posts by Categories



Widget by