Form Field Initial Value - Behavior

B

Bill Morgan

I have a website. One of the pages contains a form with
input fields. Each of the fields contains an initial value
(default value such as "Last Name", etc.).

QUESTION: I want the field initial value to disappear as
soon as the client begins typing in his actual
information, without him having to select/delete the
initial value. For example, in the [Last Name] field, the
initial, default value is "Last Name". When the client
selects that field and begins typing in his own last name,
I want that default value to disappear on the client's
first keystroke.

How do I most easily accomplish this?

Thanks in advance for any assistance you can provide ...

Bill Morgan
 
J

Jim Buyens

Att this attribute to your <input type="text"> tag:

onfocus="this.value='';"

This erases the value whenever the visitor tabs to or
clicks on the field.

Keep in mind, though, that it will also clear the field
after the visitor has filled it out, and then returns.
That's why most designers put titles or instructions near
the fields rather than inside them.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
B

Bill Morgan

Jim,

Thanks for the solution. This leads me to two more
questions:

QUESTION-1: I notice that if I select the default text so
it is highlighted, then it automatically disappears when I
start typing in new information. If there was a way to
have the text automatically highlight when the onfocus
event ocurred, then the field value would stay intact if
the client clicked on it or tabbed to it - it would only
disappear once he started typing in new information, which
is okay. Is there a way to achieve this?

QUESTION-2: I don't see any code-behind-form feature for
FP. I'm familiar with VB and VBA, but nothing else. Is the
code you suggest VB script or HTML (i.e., whatever it is,
need to read up on it).

Thanks for your help.

b.
-----Original Message-----
Att this attribute to your <input type="text"> tag:

onfocus="this.value='';"

This erases the value whenever the visitor tabs to or
clicks on the field.

Keep in mind, though, that it will also clear the field
after the visitor has filled it out, and then returns.
That's why most designers put titles or instructions near
the fields rather than inside them.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------


-----Original Message-----
I have a website. One of the pages contains a form with
input fields. Each of the fields contains an initial value
(default value such as "Last Name", etc.).

QUESTION: I want the field initial value to disappear as
soon as the client begins typing in his actual
information, without him having to select/delete the
initial value. For example, in the [Last Name] field, the
initial, default value is "Last Name". When the client
selects that field and begins typing in his own last name,
I want that default value to disappear on the client's
first keystroke.

How do I most easily accomplish this?

Thanks in advance for any assistance you can provide ...

Bill Morgan


.
.
 
J

Jim Buyens

Bill Morgan said:
Jim,

Thanks for the solution. This leads me to two more
questions:

QUESTION-1: I notice that if I select the default text so
it is highlighted, then it automatically disappears when I
start typing in new information. If there was a way to
have the text automatically highlight when the onfocus
event ocurred, then the field value would stay intact if
the client clicked on it or tabbed to it - it would only
disappear once he started typing in new information, which
is okay. Is there a way to achieve this?

I did some searching on this, and it doesn't seem to be possible.
Browsers apparently don't expose properties that set/indicate
the start and end of a selection in a text box.
QUESTION-2: I don't see any code-behind-form feature for
FP. I'm familiar with VB and VBA, but nothing else. Is the
code you suggest VB script or HTML (i.e., whatever it is,
need to read up on it).

Thanks for your help.
b.

The code I suggested is JavaScript, which is a scripting language
that runs on the browser. Like C++, it's a curly-braces-and-semicolons
language.

You can program IE in VBScript, but that doesn't work in Netscape,
Opera, or any other browsers. JavaScript works in all browsers, and
that's the attraction.

You can also write program code that runs on the Web server. This is
good for updating databases, sending mail, accessing the server's file
system, and so forth. On Windows servers, the most popular approaches
are ASP (which is slowly on the way out) and ASP.NET (which is newer).
ASP typically uses VBScript. ASP.NET uses VB.NET or C#.

On Unix servers, PHP is probably the most popular scripting language.

FrontPage has no special features for working with any of these,
except by switching to Code view so you can enter the lines of code.

(Of course, some FrontPage components generate JavaScript, ASP, or
ASP.NET code behind the scenes.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
J

Jon Spivey

Hi Bill,

I can't see exactly what you want but see how this works for you
<input type="text" value="type your name" onfocus="this.select()">

This will select the text and make it go as soon as the user starts typing


--
Cheers,
Jon
Microsoft MVP - FP

Bill said:
Jim,

Thanks for the solution. This leads me to two more
questions:

QUESTION-1: I notice that if I select the default text so
it is highlighted, then it automatically disappears when I
start typing in new information. If there was a way to
have the text automatically highlight when the onfocus
event ocurred, then the field value would stay intact if
the client clicked on it or tabbed to it - it would only
disappear once he started typing in new information, which
is okay. Is there a way to achieve this?

QUESTION-2: I don't see any code-behind-form feature for
FP. I'm familiar with VB and VBA, but nothing else. Is the
code you suggest VB script or HTML (i.e., whatever it is,
need to read up on it).

Thanks for your help.

b.
-----Original Message-----
Att this attribute to your <input type="text"> tag:

onfocus="this.value='';"

This erases the value whenever the visitor tabs to or
clicks on the field.

Keep in mind, though, that it will also clear the field
after the visitor has filled it out, and then returns.
That's why most designers put titles or instructions near
the fields rather than inside them.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
\---------------------------------------------------
Microsoft Office FrontPage 2003 Inside Out
---------------------------------------------------
Web Database Development Step by Step .NET Edition
Microsoft FrontPage Version 2002 Inside Out
Faster Smarter Beginning Programming
(All from Microsoft Press)
/--------------------------------------------------- *----------------------------------------------------



-----Original Message-----
I have a website. One of the pages contains a form with
input fields. Each of the fields contains an initial value
(default value such as "Last Name", etc.).

QUESTION: I want the field initial value to disappear as
soon as the client begins typing in his actual
information, without him having to select/delete the
initial value. For example, in the [Last Name] field, the
initial, default value is "Last Name". When the client
selects that field and begins typing in his own last name,
I want that default value to disappear on the client's
first keystroke.

How do I most easily accomplish this?

Thanks in advance for any assistance you can provide ...

Bill Morgan


.
.
 
B

Bill Morgan

Jim,

Thanks for the info. Now that I'm having to do more web
stuff, I guess I need to crack open a few new books - JAVA
being one of them.
 
G

Guest

Jon,

That's exactly what I want. Now the client doesn't need to
manually select, and the text won't delete unless he
starts typing over it. Thanks.
-----Original Message-----
Hi Bill,

I can't see exactly what you want but see how this works for you
<input type="text" value="type your name" onfocus="this.select()">

This will select the text and make it go as soon as the user starts typing


--
Cheers,
Jon
Microsoft MVP - FP

Bill said:
Jim,

Thanks for the solution. This leads me to two more
questions:

QUESTION-1: I notice that if I select the default text so
it is highlighted, then it automatically disappears when I
start typing in new information. If there was a way to
have the text automatically highlight when the onfocus
event ocurred, then the field value would stay intact if
the client clicked on it or tabbed to it - it would only
disappear once he started typing in new information, which
is okay. Is there a way to achieve this?

QUESTION-2: I don't see any code-behind-form feature for
FP. I'm familiar with VB and VBA, but nothing else. Is the
code you suggest VB script or HTML (i.e., whatever it is,
need to read up on it).

Thanks for your help.

b.
-----Original Message-----
Att this attribute to your <input type="text"> tag:

onfocus="this.value='';"

This erases the value whenever the visitor tabs to or
clicks on the field.

Keep in mind, though, that it will also clear the field
after the visitor has filled it out, and then returns.
That's why most designers put titles or instructions near
the fields rather than inside them.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
\---------------------------------------------------
Microsoft Office FrontPage 2003 Inside Out
---------------------------------------------------
Web Database Development Step by Step .NET Edition
Microsoft FrontPage Version 2002 Inside Out
Faster Smarter Beginning Programming
(All from Microsoft Press)
/---------------------------------------------------
*----------------------------------------------------



-----Original Message-----
I have a website. One of the pages contains a form with
input fields. Each of the fields contains an initial value
(default value such as "Last Name", etc.).

QUESTION: I want the field initial value to disappear as
soon as the client begins typing in his actual
information, without him having to select/delete the
initial value. For example, in the [Last Name] field, the
initial, default value is "Last Name". When the client
selects that field and begins typing in his own last name,
I want that default value to disappear on the client's
first keystroke.

How do I most easily accomplish this?

Thanks in advance for any assistance you can provide ...

Bill Morgan


.

.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top