Setting focus on a form field

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Setting focus on a form field

    When a CFM page loads, how can you set focus on a textbox so the cursor
    is already in the field?

    Thanks
    Steve
    Steve Grosz Guest

  2. Similar Questions and Discussions

    1. ASP - setting form field to insert memo
      Hi all. I am using DW's Insert Record behavior in an effort to create a form to insert a record into a MS Access database. Everything works fine -...
    2. Setting hidden field value eq to a form field value.
      Ok guys help a dumb blond out. I need to pass the value of a form field to two different file fields. Here is an example of what I have; <form...
    3. Setting Input Focus for a Field
      Hello, I've been programming in Lingo for over 5 years and have noticed over the years that people often want to know how to programmatically...
    4. Setting Focus on field when RequiredFieldValidator fails - This Works!
      There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people...
    5. Setting focus after Validating Form Items
      I have a form with about 5 or 8 textboxes and all of them have required field validators... When I submit the form, if some of this field are...
  3. #2

    Default Re: Setting focus on a form field

    <cfoutput><body onload="document.forms.#varFormFocus#.focus();"></cfoutput>

    where varFormFocus has been set to your form field name (case sensitive, must
    exactly match Form).
    For field types that can handle it (i.e. straight, not lists) substitute
    ..select() for highligthed overtyping.



    JMGibson3 Guest

  4. #3

    Default Re: Setting focus on a form field

    This has nothing to do with cfm pages, it's a general HTML form question.

    You set focus via Javascript. document.formname.fieldname.focus();
    Kronin555 Guest

  5. #4

    Default Re: Setting focus on a form field

    So if my search form is search.cfm, would it be:

    document.search.searchstring.focus();

    ??

    Steve

    Kronin555 wrote:
    > This has nothing to do with cfm pages, it's a general HTML form question.
    >
    > You set focus via Javascript. document.formname.fieldname.focus();
    Steve Grosz Guest

  6. #5

    Default Re: Setting focus on a form field

    It would be the value of the NAME parameter of your FORM or CFFORM tag in your
    template, and the name given the INPUT tag.

    Something like

    body onload="document.form_name.input_name.focus()">

    <cfform name="form_name" action="whatever.cfm" method="POST" target="_top">

    <input type="text" name="input_name" required="yes" message="whatever">

    Phil

    paross1 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139