disable (set to readonly) a textbox in javascript???


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: disable (set to readonly) a textbox in javascript???

  1. #1
    ttttony Guest

    disable (set to readonly) a textbox in javascript???


    Hi all,

    How do you set a textbox to readonly from a jscript function??

    tia

    tony


  2. #2
    shobha Guest

    Re: disable (set to readonly) a textbox in javascript???


    u can set the disable property of the text box to true..
    heres the code

    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE></TITLE>
    <script language="javascript">
    function dodisable()
    {
    document.form1.txt1.disabled="true";
    }
    </script>
    </HEAD>
    <BODY>

    <P>&nbsp;</P>
    <form id=form1 name=form1>
    <input type="text" value="shobha" name="txt1">
    <input type="button" value="Disable Text Box" onclick="dodisable()">
    </form>


    </BODY>
    </HTML>



    "ttttony" <afarrell@tccf.net> wrote:
    >
    >Hi all,
    >
    >How do you set a textbox to readonly from a jscript function??
    >
    >tia
    >
    >tony
    >



  3. #3
    Girish Guest

    Re: disable (set to readonly) a textbox in javascript???


    Hi,
    The reply given by shobha will work fine. but if need to access the value
    of the testbox on the next screen using "form.formfildname" then it won't
    be available.where as if instead of the disable property you use the readonly
    then the value of the foiled is available een after the form submission

    document.form1.txt1.readOnly=true;

    but these two solutions will work only in Internet explorer and not in netscape
    according to my experience we are not able to mnake a textfiled noneditable
    in netscape.

    Regards

    Girish
    ----------------------------------------------------------
    "shobha" <shobhaiyer@yahoo.com> wrote:
    >
    >u can set the disable property of the text box to true..
    >heres the code
    >
    ><HTML>
    ><HEAD>
    ><META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    ><TITLE></TITLE>
    ><script language="javascript">
    >function dodisable()
    >{
    >document.form1.txt1.disabled="true";
    >}
    ></script>
    ></HEAD>
    ><BODY>
    >
    ><P>*</P>
    ><form id=form1 name=form1>
    ><input type="text" value="shobha" name="txt1">
    ><input type="button" value="Disable Text Box" onclick="dodisable()">
    ></form>
    >
    >
    ></BODY>
    ></HTML>
    >
    >
    >
    >"ttttony" <afarrell@tccf.net> wrote:
    >>
    >>Hi all,
    >>
    >>How do you set a textbox to readonly from a jscript function??
    >>
    >>tia
    >>
    >>tony
    >>

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center