• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFFORM - field focus

Enthusiast ,
Jul 15, 2008 Jul 15, 2008

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

917

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Jul 15, 2008 Jul 15, 2008
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

Votes

Translate

Translate
LEGEND ,
Jul 15, 2008 Jul 15, 2008

Copy link to clipboard

Copied

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
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 15, 2008 Jul 15, 2008

Copy link to clipboard

Copied

I double checked the code and they are both in lower case

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 15, 2008 Jul 15, 2008

Copy link to clipboard

Copied

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;">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2008 Jul 15, 2008

Copy link to clipboard

Copied

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/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 15, 2008 Jul 15, 2008

Copy link to clipboard

Copied

Yep. it's all in lowercase. I added the ID="fn" to the input text field... still doesn't work :(

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2008 Jul 15, 2008

Copy link to clipboard

Copied

your form is not inside an iframe or a cfwindow or some other element
per chance?

try using document.getElementById("fn").focus() instead of
document.checkform...

i am running out of ideas here... :)


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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 15, 2008 Jul 15, 2008

Copy link to clipboard

Copied

nope, nothing weird going on at all, straight code.

I've never used CFFORM, always just FORM, and it worked fine, so I thought it must be something to do with that

How do I utilize the document.getElementById("fn").focus() ?

Thanks

Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2008 Jul 15, 2008

Copy link to clipboard

Copied

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/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 15, 2008 Jul 15, 2008

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2008 Jul 15, 2008

Copy link to clipboard

Copied

LATEST
happens to me all the time... glad you got it sorted out!

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation