Results 1 to 11 of 11

Thread: Textboxes...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Unhappy

    Hello,

    I have a textbox - "<input type="text" name="name" size="20">"

    Is there a way in which I can "lock" this textbox - ie. disallow users
    from editing whatever is inside this textbox.

    I actually want to disallow the user from entering into this AT ALL - he
    must not even be able to place the cursor within here.

    Another question... How can I set the focus to this textbox, so that the cursor is automatically
    placed within it when the page is loaded.

    Can it be done??

    Thanks,
    T

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Yes on both counts....

    To disable:
    Code:
    //Javascript:
    MyForm.MyTextBox.disabled=true;
    To set focus:
    Code:
    //Javascript:
    MyForm.MyTextBox.focus();
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  3. #3
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Oh.. stick that focus method in the window_onload() event...
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  4. #4
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    <input type="text" readonly> is part of HTML 4.0.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  5. #5
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Yes, but you can't always count on a 4.0 browser... (I hate having to code for the lowest common denominator but...)

    Also, you can not set focus to a readonly textbox or a disabled textbox. In fact, if it is disabled and you try to set focus, it will generate an error.

    So, if you are using the disabled method, enable it before setting focus.
    Last edited by monte96; Apr 24th, 2001 at 10:56 AM.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  6. #6
    bubba
    Guest

    I say, if they haven't updated their browser since 1997...

    then screw 'em.

    If you want the text box to appear disabled/readonly:

    <input TYPE="TEXT" VALUE="Yeah, baby!" disabled>

    the readonly property makes the box look normal, disabled shades it.

  7. #7
    New Member
    Join Date
    Feb 2001
    Posts
    12
    as usual im not sure if im gonna be right here or not.

    with the readonly it makes it uneditable but still looks normal as previously mentioned, the disabled command also hides the info in the field when submitted so if u submit a form with the disabled field in you wont be able to retrieve the info from within, but you can with readonly, I think...

  8. #8
    bubba
    Guest

    You are correct Jeh

    Disabled text box values can't be passed, but readonly can

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Monte96

    Hello guys,

    I only got a chance to read the replies now!! Thank you very much - this is exactly what I was looking for!!

    Monte96 (or anyone),

    Can you please give me some example code of the window_onload() event!?

    I'm not very clued up with Java. Do you just put this event right at the top of your page and it will "fire" whenever the page is loaded??

    Thanks,
    T

  10. #10
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Ok.. first off, you won't use Java, you'll use Javascript. They are similar only in name.

    The window_onload() event will fire if you put it in the BODY tag's event handler attribute like:
    Code:
    <BODY onload="window_onload()">
    You will put a script tag in the HEAD section of the page, be sure to specify the language and remember that javascript is case sensitive:
    Code:
    <HTML>
    <HEAD>
    <SCRIPT language=javascript>
    function window_onload()
    {
    //Put your code for the onload event here
    }
    </SCRIPT>
    </HEAD>
    <BODY onload="window_onload()">
    ...
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Talking

    Thanks Monte96, and thanks for the answer on the formatting of currency values in my other thread.

    T

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width