|
-
Apr 23rd, 2001, 03:05 PM
#1
Thread Starter
Hyperactive Member
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
-
Apr 23rd, 2001, 08:34 PM
#2
Frenzied Member
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..
-
Apr 23rd, 2001, 08:34 PM
#3
Frenzied Member
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..
-
Apr 24th, 2001, 06:35 AM
#4
Black Cat
<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.
-
Apr 24th, 2001, 10:46 AM
#5
Frenzied Member
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..
-
Apr 24th, 2001, 11:22 AM
#6
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.
-
Apr 24th, 2001, 11:43 AM
#7
New Member
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...
-
Apr 24th, 2001, 12:45 PM
#8
You are correct Jeh
Disabled text box values can't be passed, but readonly can
-
May 9th, 2001, 01:15 AM
#9
Thread Starter
Hyperactive Member
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
-
May 9th, 2001, 12:07 PM
#10
Frenzied Member
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..
-
May 9th, 2001, 02:27 PM
#11
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|