Ask a Question related to Coldfusion Database Access, Design and Development.
-
sweetyp2005 #1
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
-
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... -
about cfinsert tag error!
please look this code: <cfif IsDefined("Form.posted")> <cfinsert datasource="test" tablename="users"... -
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... -
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... -
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... -
Dan Bracuk #2
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
-
sweetyp2005 #3
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
-
Dan Bracuk #4
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
-
efecto747 #5
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



Reply With Quote

