Peter,
Great script, but it left me wondering about users (like me) who don't
click on form elements after the first one. A little more embedded code,
and a little less <script> code, and you can make it work when tabbing
through the fields, too:
<script language="JavaScript1.2">
//Highlight form element- � Dynamic Drive (www.dynamicdrive.com)
//Modified by Humankind Systems (http://hksi.net/) to work when
//tabbing through the fields.
//For full source code, 100's more DHTML scripts, and TOS,
//visit http://www.dynamicdrive.com
var highlightcolor="lightyellow"
// Only works in IE4+ and NS6+, so sniff out NS4 to prevent errors
var highlightableBrowser = document.getElementById || document.all
//Function to highlight form element
function on(e){
if (highlightableBrowser)
e.style.backgroundColor=highlightcolor
}
function off(e){
if (highlightableBrowser)
e.style.backgroundColor=''
}
</script>
<form name="applicationform" method="post" action="index.cfm">
1<input type=text name=field1 onFocus="on(this);"
onBlur="off(this);"><br>
2<input type=text name=field2 onFocus="on(this);"
onBlur="off(this);"><br>
3<input type=text name=field3 onFocus="on(this);"
onBlur="off(this);"><br>
4<input type=text name=field4 onFocus="on(this);"
onBlur="off(this);"><br>
</form>
Ron Hornbaker
President/CTO
. . . . . . . . . . . . http://humankindsystems.com
. . . . . . . . . . . . w e c o d e. w e c a r e.
> -----Original Message-----
> From: Tilbrook, Peter [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 26, 2001 7:22 PM
> To: CF-Talk
> Subject: RE: Highlight Script
>
>
> Try this:
>
> <script language="JavaScript1.2">
> //Highlight form element- � Dynamic Drive (www.dynamicdrive.com)
> //For full source code, 100's more DHTML scripts, and TOS,
> //visit http://www.dynamicdrive.com
>
> var highlightcolor="lightyellow"
>
> var ns6=document.getElementById&&!document.all
> var previous=''
> var eventobj
>
> //Regular expression to highlight only form elements
> var intended=/INPUT|TEXTAREA|SELECT|OPTION/
>
> //Function to check whether element clicked is form element
> function checkel(which){
> if (which.style&&intended.test(which.tagName)){
> if (ns6&&eventobj.nodeType==3)
> eventobj=eventobj.parentNode.parentNode
> return true
> }
> else
> return false
> }
>
> //Function to highlight form element
> function highlight(e){
> eventobj=ns6? e.target : event.srcElement
> if (previous!=''){
> if (checkel(previous))
> previous.style.backgroundColor=''
> previous=eventobj
> if (checkel(eventobj))
> eventobj.style.backgroundColor=highlightcolor
> }
> else{
> if (checkel(eventobj))
> eventobj.style.backgroundColor=highlightcolor
> previous=eventobj
> }
> }
> </script>
>
>
> Your CFFORM tag should look something like this:
>
> <cfform name="applicationform" method="post" action="index.cfm"
> enctype="multipart/form-data" passthrough="onClick='highlight(event)
> '">
> <input type="hidden" name="fuseaction" value="SubmitApplication">
>
> Cheers!
>
> Peter Tilbrook
> ColdFusion Applications Developer
> Australia New Zealand Food Authority
> Boeing House
> 55 Blackall Street
> BARTON ACT 2600
> Ph: +61-2-6271-2671
> Fax: +61-2-6271-2278
>
> http://www.anzfa.gov.au
>
>
>
> **********************************************************************
>
> This transmission is intended only for the use of the addressee(s)
> and may contain confidential or legally privileged information.
> If you are
> not the intended recipient, you are notified that any use or
> dissemination
> of this communication is strictly prohibited. If you have received this
> transmission in error, please notify the ANZFA IT helpdesk
> prior to deleting
> all copies of this transmission together with any attachments.
>
> ANZFA helpdesk:
>
> E-mail: [EMAIL PROTECTED]
> This footnote also confirms that this email message has been swept by
> MIMEsweeper for the presence of computer viruses.
>
> www.mimesweeper.com
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists