Skip to main content
Inspiring
July 15, 2008
Answered

CFFORM - field focus

  • July 15, 2008
  • 3 replies
  • 1187 views
I am using CFFORM to create a form including a CFCALENDAR, the problem I have is that the first field which is a text field (name: FN) is not focused.

I added this code to the BODY tag, and the name matches the name of the CFFORM (checkform), yet the FN field will not function

onload="document.checkform.fn.focus();"

Appreciate any help

Mark
This topic has been closed for replies.
Correct answer ACS LLC
put into a function in the page's HEAD and call the function form the
BODY's onload event:

<script>
setFocus = function(){
document.getElementById("fn").focus();
}
</script>

<body onload="setFocus()">

make sure your fn input field has an ID="fn" attribute.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

thanks, your solution worked... however it did not at first... then I noticed, the BODY tag had a DIV after it right next to it, I was dropping the ONLOAD into the DIV...duhhhhh.. one of those things you stare at for hours and can't see the wood for the trees!

Thanks for the help

3 replies

Inspiring
July 15, 2008
cfinput or input does not matter.
add an ID attribute to your input field, with same value ('fn')...
make sure checkform is in correct case as well...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
ACS LLCAuthor
Inspiring
July 15, 2008
Yep. it's all in lowercase. I added the ID="fn" to the input text field... still doesn't work :(
ACS LLCAuthor
Inspiring
July 15, 2008
Just a thought, for the text input, I'm using this, should I be using CFINPUT??

<input type="text" name="fn" size="15" maxlength="25" style="background-color: #CCE5FF;

border-width: 1px; border-color: #000000; color: black; font-size: 20pt;">
Inspiring
July 15, 2008
Mark,

The input name/id (FN) needs to be the same case as the onload call.

So if the input is FN the onload would look like this:

onload="document.checkform.FN.focus();"

--
Ken Ford
Adobe Community Expert - Dreamweaver/ColdFusion
Fordwebs, LLC
http://www.fordwebs.com


"ACS LLC" <webforumsuser@macromedia.com> wrote in message news:g5iq1v$a48$1@forums.macromedia.com...
>I am using CFFORM to create a form including a CFCALENDAR, the problem I have
> is that the first field which is a text field (name: FN) is not focused.
>
> I added this code to the BODY tag, and the name matches the name of the CFFORM
> (checkform), yet the FN field will not function
>
> onload="document.checkform.fn.focus();"
>
> Appreciate any help
>
> Mark
>
ACS LLCAuthor
Inspiring
July 15, 2008
I double checked the code and they are both in lower case