Solved

Input type readonly

Posted on 2011-02-20
5
383 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
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…

742 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