Professional Web Applications Themes

Populating form from javascript - Macromedia ColdFusion

I am trying to give the user an option to populate an entire form with one value using javascript, but my textbox names are dynamic and I am not sure how to reference them in the javascript. Heres the code and the javascript that doesn't work. Thanks for help:...

  1. #1

    Default Populating form from javascript

    I am trying to give the user an option to populate an entire form with one
    value using javascript, but my textbox names are dynamic and I am not sure how
    to reference them in the javascript. Heres the code and the javascript that
    doesn't work. Thanks for help:

    Tulsa Guest

  2. #2

    Default Re: Populating form from javascript

    check this sample. this is from cfform.com

    <cfscript> qNames = queryNew("id,firstname,lastname,city,state,zip");
    queryAddRow(qNames); querySetCell(qNames, "id", "1");
    querySetCell(qNames, "firstname", "Mike"); querySetCell(qNames, "lastname",
    "Nimer"); querySetCell(qNames, "city", "Boston"); querySetCell(qNames,
    "state", "MA"); querySetCell(qNames, "zip", "O2127");
    queryAddRow(qNames); querySetCell(qNames, "id", "1");
    querySetCell(qNames, "firstname", "Bob"); querySetCell(qNames, "lastname",
    "Jones"); querySetCell(qNames, "city", "Salt Lake City");
    querySetCell(qNames, "state", "UT"); querySetCell(qNames, "zip", "84111");
    queryAddRow(qNames); querySetCell(qNames, "id", "3");
    querySetCell(qNames, "firstname", "Chris"); querySetCell(qNames, "lastname",
    "Smith"); querySetCell(qNames, "city", "Las Vegas"); querySetCell(qNames,
    "state", "NV"); querySetCell(qNames, "zip", "55555");
    queryAddRow(qNames); querySetCell(qNames, "id", "4");
    querySetCell(qNames, "firstname", "Susan"); querySetCell(qNames, "lastname",
    "McFoo"); querySetCell(qNames, "city", "Boston"); querySetCell(qNames,
    "state", "MA"); querySetCell(qNames, "zip", "02466");</cfscript><cfform
    format="Flash"> <cfgrid name="UsersGrid" format="Flash"
    query="qNames" maxRows="5" rowheaders="No" onchange="for (var
    i:Number = 0; i<state.length; i++) {if (state.getItemAt().data ==
    UsersGrid.selectedItem.state) state.selectedIndex = i}">
    <cfgridcolumn name="id"> <cfgridcolumn name="firstname"
    header="First Name"> <cfgridcolumn name="lastname" header="Last
    Name"> <cfgridcolumn name="city" header="city">
    <cfgridcolumn name="state" header="state"> </cfgrid> <cfinput
    type="text" name="firstname" label="First Name"
    bind="{UsersGrid.dataProvider[UsersGrid.selectedIndex]['firstname']}"
    onChange="UsersGrid.dataProvider.editField(UsersGr id.selectedIndex,
    'firstname', firstname.text);"> <cfinput type="text" name="lastname"
    label="Last Name"
    bind="{UsersGrid.dataProvider[UsersGrid.selectedIndex]['lastname']}"
    onChange="UsersGrid.dataProvider.editField(UsersGr id.selectedIndex, 'lastname',
    lastname.text);"> <cfselect name="state" width="200" size="1"
    label="State"
    onchange="UsersGrid.dataProvider.editField(UsersGr id.selectedIndex, 'state',
    state.selectedItem.data);"> <option value="MA">Boston</option>
    <option value="CA">California</option> <option value="NV">Las
    Vegas</option> <option value="UT">Salt Lake City</option> </cfselect>
    <cfformgroup type="horizontal"> <cfinput type="Submit"
    name="submitBtn" value="Save"> </cfformgroup></cfform>

    ayhanyildiz Guest

Similar Threads

  1. javascript within CF form
    By [w]alterego in forum Coldfusion - Getting Started
    Replies: 1
    Last Post: June 22nd, 12:22 AM
  2. Dynamically populating form fields
    By galeemma in forum Dreamweaver AppDev
    Replies: 4
    Last Post: April 21st, 05:37 PM
  3. Web Form Populating Database
    By bbjohn in forum Web Design
    Replies: 1
    Last Post: August 23rd, 01:57 PM
  4. Replies: 3
    Last Post: May 13th, 12:15 AM
  5. [PHP] PHP, JavaScript and populating DropDowns
    By John Manko in forum PHP Development
    Replies: 1
    Last Post: July 31st, 03:27 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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