Solved

Input type readonly

Posted on 2011-02-20
5
369 Views
Last Modified: 2012-06-27
See attached html. Note type readonly on element subjo.

Not onChange function on element  subj.

None of this works. The element subjo accepts typing when the page is loaded. I'm using FireFox; I checked Error Console, no Javascript errors.

I also included css in case you need it.

What's wrong?
send-message.txt
mainr3.css
0
Comment
Question by:Richard Korts
  • 2
  • 2
5 Comments
 
LVL 15

Expert Comment

by:ludofulop
ID: 34938768
hi, there is no input type 'readonly', but there is a html attribute 'readonly'.
you can set it in html:
<input type="text" readonly="readonly" .... />
or using javascript:
document.st.subjo.readonly = true;      
0
 
LVL 4

Expert Comment

by:LAMASE
ID: 34938785
type="readonly"??
It simply doesn't exists, so the browser use the default "input" type.
Use
<input type="text" readonly>
0
 
LVL 4

Expert Comment

by:LAMASE
ID: 34938791
ps, for a modern html, use
<input type="text" name="subjo" readonly="readonly">
0
 

Author Comment

by:Richard Korts
ID: 34938953
To all,

Thanks. I got it to partially work. Form field like this:

                        <td><input type="text" readonly name="subjo" size="30" class="pt8">&nbsp;<font size="-1">(Please enter a subject if "Other" is selected)</font></td>

But the onChange in the select element DOES NOT change the readonly attribute.

I tried it as follows and also with true & false; neither works.

      function chk_other() {
            if (document.st.subj.value == "Other") {
                  document.st.subjo.readonly = "";
            } else {
                  document.st.subjo.value = "";
                  document.st.subjo.readonly = "readonly";      
            }
            return true;
      }            
0
 
LVL 15

Accepted Solution

by:
ludofulop earned 500 total points
ID: 34939004
try this:

      function chk_other() {
        if (document.st.subj.options[document.st.subj.selectedIndex].value != "Other") {
              document.st.subjo.readOnly = true;
        } else {
              document.st.subjo.value = "";
              document.st.subjo.readOnly = false;
        }
            return true;
      }            
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now