Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Input type readonly

Posted on 2011-02-20
5
Medium Priority
?
396 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

649 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