Solved

Input type readonly

Posted on 2011-02-20
5
380 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Find out what you should include to make the best professional email signature for your organization.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
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 …

831 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