aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes need help clearing fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "need help clearing fields" Watch "need help clearing fields" New topic
Author

need help clearing fields

Geoff Bell
Greenhorn

Joined: Jul 05, 2002
Posts: 3
i am doing the website for a girls grammar school where i am employed and in on alumni page i have a form created in dreamweaver where they can fill-in their details. i placed mock entries in the fields to give them inspiration of what to write, but would like this info to disappear as soon as the past pupil clicks within the field to make their entry. can someone tell me what code i need to insert. many thanks in advance.
here is a link to the page in question with the form http://www.girlsacademy.org.uk/pages/pastpupils.html
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
This is really a JavaScript question, so I've moved it to the HTML/JavaScript forum for you.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

You could inside the input tag put this:

on Click should be one word..
BUT it does not work in Netscape 4.x!!
/Rene
[ July 05, 2002: Message edited by: Rene Larsen ]

Regards, Rene Larsen
Dropbox Invite
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I don't think you need the "javascript:" prefix in an on click handler. The prefix is only used for attributes which would normally take a URL as a parameter like <a href='javascript:window.close()'>close this window</a>.
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Yes, you are right...
It is hard to remember when you get old
/Rene
Charlie Sturman
Ranch Hand

Joined: Apr 04, 2002
Posts: 112

Note I had to put a space in on click just for posting on this forum.You will need to emove the space from on click.

folded long lines
[ July 05, 2002: Message edited by: Frank Carver ]
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
I'm not sure about removing content - they might want to just correct something, not to retype everything. I think it will be more clear, if you will just select content of a field.
And instead of onclick you might want to use onfocus - this event happends in all browsers, and it also will occur, if user reached a field using Tab button.
so, it will be something like
<input onfocus="this.select()"
Geoff Bell
Greenhorn

Joined: Jul 05, 2002
Posts: 3
thanks for your help. the "clearField(this);" did what i was asking for. i will alter the code my hand for now, but will see if it is possible to do it from within dreamweaver. (sorry if i insulted any hand-coders, but i am one of those that rely of wysiwyg. LOL.)
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Hello there,
I sat down and typed up this script for you. It will remove the default text without removing the users input. It will make them happy is they typed in all the information.
I placed it on my site with an explaination about it. I thought this was a good topic to add to my scripts, thanks for the idea.
http://www10.brinkster.com/a1ien51/Scripts/RemoveDefaultText.htm
If you have any problems geting it to work, just post it here.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: need help clearing fields