suggestion box, has text and text goes when you click in the box, how?

  • Thread starter thanks for the help mate
  • Start date
T

thanks for the help mate

I have a suggestion box and want to have 'please enter text here' in the box
and have that text go when they click in the box.

how do I do this?


thank you

J

using FrontPage
 
R

Rick Budde

You don't say where you want the text to go but I will
assume you want it to go to you.

If so, look into Front Page Forms (see Front Page help).
You can have the text sent to your email, a database, CSV
file.

If this is what you want, be aware that to utilitize
Front Page forms your host must support the Front Page
Extensions (a set of server side scripts that will
process the text and forward it to your email address).

If your host does not support the Extensions, contact
them to see if they provide for some other forms handling
methods ... many do.
 
J

Jens Peter Karlsen[FP MVP]

The first part is easy, just specify the value in properties for the
form field.
The second requires some JavaScript. Something like this:

function clearIt(){
if (form[0].formfieldname.value != "Please enter text here"){
form[0].formfieldname.value = ""
}
}

And then you add an onClick action to the form field that calls the
function.
Notice that "formfieldname" should be the real name assigned to the form
field in question.

Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
 
T

thanks for the help mate

Re: suggestion box, has text and text goes when you click in the box, how?thank you
The first part is easy, just specify the value in properties for the form field.
The second requires some JavaScript. Something like this:

function clearIt(){
if (form[0].formfieldname.value != "Please enter text here"){
form[0].formfieldname.value = ""
}
}

And then you add an onClick action to the form field that calls the function.
Notice that "formfieldname" should be the real name assigned to the form field in question.

Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
 
M

Murray

Re: suggestion box, has text and text goes when you click in the box,
how?Actually, this is going to do the wrong thing!

It should be -

if (form[0].formfieldname.value = "Please enter text here"){

otherwise, you would never be able to enter anything, no? 8)


--
Murray

The first part is easy, just specify the value in properties for the form
field.
The second requires some JavaScript. Something like this:
function clearIt(){
if (form[0].formfieldname.value != "Please enter text here"){
form[0].formfieldname.value = ""
}
}
And then you add an onClick action to the form field that calls the
function.
Notice that "formfieldname" should be the real name assigned to the form
field in question.
Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
 
J

Jon Spivey

Re: suggestion box, has text and text goes when you click in the box, how?Jens,
That's the wrong way around also the syntax is off - basically it's saying if the value is NOT "Please enter text here" clear the box - so the user would never be able to type anything :) This is how to do it - there's no need for a function call
<input type="text" value="Enter Text Here" onfocus="if(this.value==this.defaultValue)this.value='';">

We only clear the box when the value IS the default value "Enter Text Here"

--
Cheers,
Jon
Microsoft MVP

The first part is easy, just specify the value in properties for the form field.
The second requires some JavaScript. Something like this:

function clearIt(){
if (form[0].formfieldname.value != "Please enter text here"){
form[0].formfieldname.value = ""
}
}

And then you add an onClick action to the form field that calls the function.
Notice that "formfieldname" should be the real name assigned to the form field in question.

Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
 
M

Murray

Re: suggestion box, has text and text goes when you click in the box,
how?That's how I do it, Jon, and in fact, I add a bit so that if the field
is blurred with a value of "" its value is reset to the original -

<input type="text" name="n" value="Your message"
onFocus="if(this.value==this.defaultValue)this.value=''"
onBlur="if(this.value=='')this.value=this.defaultValue>

--
Murray

Jens,
That's the wrong way around also the syntax is off - basically it's saying
if the value is NOT "Please enter text here" clear the box - so the user
would never be able to type anything :) This is how to do it - there's no
need for a function call
<input type="text" value="Enter Text Here"
onfocus="if(this.value==this.defaultValue)this.value='';">

We only clear the box when the value IS the default value "Enter Text Here"

--
Cheers,
Jon
Microsoft MVP

The first part is easy, just specify the value in properties for the form
field.
The second requires some JavaScript. Something like this:
function clearIt(){
if (form[0].formfieldname.value != "Please enter text here"){
form[0].formfieldname.value = ""
}
}
And then you add an onClick action to the form field that calls the
function.
Notice that "formfieldname" should be the real name assigned to the form
field in question.
Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
 
J

Jon Spivey

That's a good solution. Of course if you wanted this on a few form fields it
might be cleaner to stick the code into a function then attaching the
onfocus/onblur to the fields with script.
<script type="text/javascript">
function setForm(){
var a = document.forms[0].elements;
for(i=0;i<a.length;i++){if(a.type=='text'){
a.onfocus = function(){if(this.value==this.defaultValue)this.value='';}
a.onblur = function(){if(!this.value)this.value=this.defaultValue;}}}}
window.onload=setForm;
</script>

<body>
<form......
<input type="text" name="a" value="Enter Text for This Field">
<input type="text" name="b" value="Enter Text for This Field">
<input type="text" name="c" value="Enter Text for This Field">

Just for the sake of saving some typing........

--
Cheers,
Jon
Microsoft MVP

Murray said:
Re: suggestion box, has text and text goes when you click in the box,
how?That's how I do it, Jon, and in fact, I add a bit so that if the field
is blurred with a value of "" its value is reset to the original -

<input type="text" name="n" value="Your message"
onFocus="if(this.value==this.defaultValue)this.value=''"
onBlur="if(this.value=='')this.value=this.defaultValue>

--
Murray

Jens,
That's the wrong way around also the syntax is off - basically it's
saying if the value is NOT "Please enter text here" clear the box - so the
user would never be able to type anything :) This is how to do it -
there's no need for a function call
<input type="text" value="Enter Text Here"
onfocus="if(this.value==this.defaultValue)this.value='';">

We only clear the box when the value IS the default value "Enter Text
Here"

--
Cheers,
Jon
Microsoft MVP

The first part is easy, just specify the value in properties for the form
field.
The second requires some JavaScript. Something like this:
function clearIt(){
if (form[0].formfieldname.value != "Please enter text here"){
form[0].formfieldname.value = ""
}
}
And then you add an onClick action to the form field that calls the
function.
Notice that "formfieldname" should be the real name assigned to the form
field in question.
Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
-----Original Message-----
From: thanks for the help mate [mailto:123]
Posted At: 13. februar 2005 19:01
Posted To: microsoft.public.frontpage.programming
Conversation: suggestion box, has text and text goes when you
click in the box, how?
Subject: suggestion box, has text and text goes when you
click in the box, how?


I have a suggestion box and want to have 'please enter text
here' in the box and have that text go when they click in the box.

how do I do this?


thank you

J

using FrontPage
 
M

Murray

Yes, definitively! 8)

--
Murray

Jon Spivey said:
That's a good solution. Of course if you wanted this on a few form fields
it might be cleaner to stick the code into a function then attaching the
onfocus/onblur to the fields with script.
<script type="text/javascript">
function setForm(){
var a = document.forms[0].elements;
for(i=0;i<a.length;i++){if(a.type=='text'){
a.onfocus = function(){if(this.value==this.defaultValue)this.value='';}
a.onblur = function(){if(!this.value)this.value=this.defaultValue;}}}}
window.onload=setForm;
</script>

<body>
<form......
<input type="text" name="a" value="Enter Text for This Field">
<input type="text" name="b" value="Enter Text for This Field">
<input type="text" name="c" value="Enter Text for This Field">

Just for the sake of saving some typing........

--
Cheers,
Jon
Microsoft MVP

Murray said:
Re: suggestion box, has text and text goes when you click in the box,
how?That's how I do it, Jon, and in fact, I add a bit so that if the
field is blurred with a value of "" its value is reset to the original -

<input type="text" name="n" value="Your message"
onFocus="if(this.value==this.defaultValue)this.value=''"
onBlur="if(this.value=='')this.value=this.defaultValue>

--
Murray

Jens,
That's the wrong way around also the syntax is off - basically it's
saying if the value is NOT "Please enter text here" clear the box - so
the user would never be able to type anything :) This is how to do it -
there's no need for a function call
<input type="text" value="Enter Text Here"
onfocus="if(this.value==this.defaultValue)this.value='';">

We only clear the box when the value IS the default value "Enter Text
Here"

--
Cheers,
Jon
Microsoft MVP

The first part is easy, just specify the value in properties for the form
field.
The second requires some JavaScript. Something like this:
function clearIt(){
if (form[0].formfieldname.value != "Please enter text here"){
form[0].formfieldname.value = ""
}
}
And then you add an onClick action to the form field that calls the
function.
Notice that "formfieldname" should be the real name assigned to the form
field in question.
Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
-----Original Message-----
From: thanks for the help mate [mailto:123]
Posted At: 13. februar 2005 19:01
Posted To: microsoft.public.frontpage.programming
Conversation: suggestion box, has text and text goes when you
click in the box, how?
Subject: suggestion box, has text and text goes when you
click in the box, how?


I have a suggestion box and want to have 'please enter text
here' in the box and have that text go when they click in the box.

how do I do this?


thank you

J

using FrontPage
 
T

thanks for the help mate

<input type="text" name="n" value="Your message"
onFocus="if(this.value==this.defaultValue)this.value=''"
onBlur="if(this.value=='')this.value=this.defaultValue">


!
note the added
quote mark above at the end.

now it works

thank you anyway.

this has been a GREAT help to me


J



Murray said:
Re: suggestion box, has text and text goes when you click in the box,
how?That's how I do it, Jon, and in fact, I add a bit so that if the field
is blurred with a value of "" its value is reset to the original -

<input type="text" name="n" value="Your message"
onFocus="if(this.value==this.defaultValue)this.value=''"
onBlur="if(this.value=='')this.value=this.defaultValue>

--
Murray

Jens,
That's the wrong way around also the syntax is off - basically it's
saying if the value is NOT "Please enter text here" clear the box - so the
user would never be able to type anything :) This is how to do it -
there's no need for a function call
<input type="text" value="Enter Text Here"
onfocus="if(this.value==this.defaultValue)this.value='';">

We only clear the box when the value IS the default value "Enter Text
Here"

--
Cheers,
Jon
Microsoft MVP

The first part is easy, just specify the value in properties for the form
field.
The second requires some JavaScript. Something like this:
function clearIt(){
if (form[0].formfieldname.value != "Please enter text here"){
form[0].formfieldname.value = ""
}
}
And then you add an onClick action to the form field that calls the
function.
Notice that "formfieldname" should be the real name assigned to the form
field in question.
Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
-----Original Message-----
From: thanks for the help mate [mailto:123]
Posted At: 13. februar 2005 19:01
Posted To: microsoft.public.frontpage.programming
Conversation: suggestion box, has text and text goes when you
click in the box, how?
Subject: suggestion box, has text and text goes when you
click in the box, how?


I have a suggestion box and want to have 'please enter text
here' in the box and have that text go when they click in the box.

how do I do this?


thank you

J

using FrontPage
 
M

Murray

Yes. Oops.

I'm glad I got you most of the way there! 8)

--
Murray

thanks for the help mate said:
<input type="text" name="n" value="Your message"
onFocus="if(this.value==this.defaultValue)this.value=''"
onBlur="if(this.value=='')this.value=this.defaultValue">


!
note the
added quote mark above at the end.

now it works

thank you anyway.

this has been a GREAT help to me


J



Murray said:
Re: suggestion box, has text and text goes when you click in the box,
how?That's how I do it, Jon, and in fact, I add a bit so that if the
field is blurred with a value of "" its value is reset to the original -

<input type="text" name="n" value="Your message"
onFocus="if(this.value==this.defaultValue)this.value=''"
onBlur="if(this.value=='')this.value=this.defaultValue>

--
Murray

Jens,
That's the wrong way around also the syntax is off - basically it's
saying if the value is NOT "Please enter text here" clear the box - so
the user would never be able to type anything :) This is how to do it -
there's no need for a function call
<input type="text" value="Enter Text Here"
onfocus="if(this.value==this.defaultValue)this.value='';">

We only clear the box when the value IS the default value "Enter Text
Here"

--
Cheers,
Jon
Microsoft MVP

The first part is easy, just specify the value in properties for the form
field.
The second requires some JavaScript. Something like this:
function clearIt(){
if (form[0].formfieldname.value != "Please enter text here"){
form[0].formfieldname.value = ""
}
}
And then you add an onClick action to the form field that calls the
function.
Notice that "formfieldname" should be the real name assigned to the form
field in question.
Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
-----Original Message-----
From: thanks for the help mate [mailto:123]
Posted At: 13. februar 2005 19:01
Posted To: microsoft.public.frontpage.programming
Conversation: suggestion box, has text and text goes when you
click in the box, how?
Subject: suggestion box, has text and text goes when you
click in the box, how?


I have a suggestion box and want to have 'please enter text
here' in the box and have that text go when they click in the box.

how do I do this?


thank you

J

using FrontPage
 

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