Solved

Input type readonly

Posted on 2011-02-20
5
381 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
Jquery form 9 38
alert on input text 2 23
Hide and Unhide Table 6 24
Add - in a loop to first and last element. 6 31
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses how to create an extensible mechanism for linked drop downs.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

680 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