cfinsert from javascript

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default cfinsert from javascript

    I have write javascript to create form field when button is click.

    function addEvent(myTable){
    var lastRow = myTable.rows.length;
    var x1=myTable.insertRow(lastRow);
    var a=x1.insertCell(0);
    var a1=x1.insertCell(1);
    var x2=myTable.insertRow(lastRow+1);
    var b=x2.insertCell(0);
    var b1=x2.insertCell(1);
    var x3=myTable.insertRow(lastRow+2);
    var c=x3.insertCell(0);
    var c1=x3.insertCell(1);
    var x4=myTable.insertRow(lastRow+3);
    var d=x4.insertCell(0);
    var d1=x4.insertCell(1);
    var x5=myTable.insertRow(lastRow+4);
    var e=x5.insertCell(0);
    var e1=x5.insertCell(1);
    var x6=myTable.insertRow(lastRow+5);
    var f=x6.insertCell(0);
    var f1=x6.insertCell(1);
    var x7=myTable.insertRow(lastRow+6);
    var g=x7.insertCell(0);
    var g1=x7.insertCell(1);
    var x8=myTable.insertRow(lastRow+7);
    var h=x8.insertCell(0);
    var h1=x8.insertCell(1);
    a.innerHTML="Event Date";
    a1.innerHTML='<input type="text">' + "Pick-Up Time" + '<input type="text">';
    b.innerHTML="Event Date End";
    b1.innerHTML='<input type="text">' + "Drop-Off Time" + '<input type="text">';
    c.innerHTML="Coach";
    c1.innerHTML="<select size=1 name='Loc' id='Loc'><option selected>Select a
    Location<option value=1>North East<option value=2>Soth America<option
    value=3>Canada</select>";
    d.innerHTML="Driver";
    d1.innerHTML="<select size=1 name='Loc' id='Loc'><option selected>Select a
    Location<option value=1>North East<option value=2>Soth America<option
    value=3>Canada</select>";
    e.innerHTML="Origination";
    e1.innerHTML='<input type="text">';
    f.innerHTML="Destination";
    f1.innerHTML='<input type="text">';
    g.innerHTML="Itinerary";
    g1.innerHTML='<input type="textarea">';
    h.innerHTML="Pax";
    h1.innerHTML='<input type="text">';
    }

    Then I want to insert value that user type in in database by using cfinsert.
    This javascript function can be called multiple time. How do i use cfloop and
    cfinsert to access database in this case.
    Thanks,


    sweetyp2005 Guest

  2. Similar Questions and Discussions

    1. cfinsert help
      I would like to have people insert information into a database. It's a single table in a database, so I thought I would try <cfinsert> I'm...
    2. about cfinsert tag error!
      please look this code: <cfif IsDefined("Form.posted")> <cfinsert datasource="test" tablename="users"...
    3. insert using cfinsert
      I have been trying to upgrade my server from CF 5 to CF 7. I have a table as keywords with the attributes as follows: ID int (primary key) keyword...
    4. CFInsert
      Hi. I was hoping I could get help on an issue. I am using CFInsert to add data from a form into two tables that are related. Table 1: Members...
    5. CFinsert misbehaves
      Any ideas why a CFinsert tag would work on my partner's desktop and not on my laptop? Both are using CF 6.0 and MS Access database. All the...
  3. #2

    Default Re: cfinsert from javascript

    At some point the user has to submit the form. Write your insert code on whatever template receives the values.
    Dan Bracuk Guest

  4. #3

    Default Re: cfinsert from javascript

    already have submit button to submit form in some point. But I dont know how to loop cfinsert to insert value to database everytime this javascript function is called
    sweetyp2005 Guest

  5. #4

    Default Re: cfinsert from javascript

    What you are trying to do is not possible. Javascript runs on the client
    machine and writes a form to the user's machine.

    Inserting database records depends on cold fusion code which runs on the
    server.

    Dan Bracuk Guest

  6. #5

    Default Re: cfinsert from javascript

    Well you can do this sort of thing if you really want to but you have to muck
    around with hidden frames and its quite a bit more work.

    You'd need to set up a frameset with a main frame which takes up the visible
    space on the page and is where your output is displayed and an "invisible"
    frame with a height of 1 pixel:

    <frameset rows="*,1" framespacing="0" frameborder="0" name="fs">
    <frame src="main.cfm" name="main" frameborder="0" scrolling="Auto"
    tabindex="32767">
    <frameset cols="100%" framespacing="0" frameborder="0" name="fsi">
    <frame src="blank.cfm" name="invis1" frameborder="1" scrolling="Auto"
    tabindex="-1">
    </frameset>
    </frameset>

    You'd then set the "target" attribute on the form tag to point to the
    invisible frame (target="invis1"). When the form is submitted it submits the
    form to the hidden frame and your form in the main frame remains intact. Of
    course you'd then need to write some code to clear the form fields or refresh
    the page or whatever it is you want to happen after the button is pressed.

    This probably isn't for the faint hearted - it takes a good understanding of
    Javascript and the DOM to make it work well. I just put this in to show it can
    be done if its really needed but you're probably better off just looking for a
    simpler way to handle your form.

    cheers.

    efecto747 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