[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.frontpage.programming

Form Field Initial Value - Behavior

Bill Morgan

4/16/2004 4:59:00 PM

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


6 Answers

Jim Buyens

4/16/2004 5:50:00 PM

0

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.inter...
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
>
>
>.
>

Bill Morgan

4/16/2004 9:17:00 PM

0

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.inter...
>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
>>
>>
>>.
>>
>.
>

news

4/17/2004 5:10:00 PM

0

"Bill Morgan" <willmorgan@lisco.com> wrote in message news:<00c301c423f8$25032080$a501280a@phx.gbl>...
> 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.inter...
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)
|/---------------------------------------------------
*----------------------------------------------------

Jon Spivey

4/18/2004 12:48:00 PM

0

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 Morgan wrote:
> 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.inter...
>> 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
>>>
>>>
>>> .
>>>
>> .


Bill Morgan

4/18/2004 1:17:00 PM

0

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.
>-----Original Message-----
>"Bill Morgan" <willmorgan@lisco.com> wrote in message
news:<00c301c423f8$25032080$a501280a@phx.gbl>...
>> 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.inter...
>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)
>|/---------------------------------------------------
>*----------------------------------------------------
>.
>

=?Utf-8?B?cm9kY2hhcg==?=

4/18/2004 1:25:00 PM

0

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 Morgan wrote:
>> 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.inter...
>>> 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
>>>>
>>>>
>>>> .
>>>>
>>> .
>
>
>.
>