•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 361,899 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,426 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser:
Views: 5691 | Replies: 3
![]() |
•
•
Join Date: Oct 2005
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
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.
I already have the submit button to submit form at some point, but I dont know how to loop cfinsert to insert value in database.
Please help. Thanks
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.
I already have the submit button to submit form at some point, but I dont know how to loop cfinsert to insert value in database.
Please help. Thanks
•
•
•
•
Originally Posted by sweetyp
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.
I already have the submit button to submit form at some point, but I dont know how to loop cfinsert to insert value in database.
Please help. Thanks
what kind of DB are you running?? I are you on a Windows Server or Linux Server? I find it easier to get quicker results off of PHP or ASP.
•
•
Join Date: Sep 2005
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Originally Posted by sweetyp
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.
I already have the submit button to submit form at some point, but I dont know how to loop cfinsert to insert value in database.
Please help. Thanks
You need to name your form fields, and then pass a list of the form fields to the CFINSERT statement. Make sure you have a table in your data source that has fields defined for all the elements in your form. Or you can just manually write an SQL statment and stick that into a CFQUERY tag. Sounds like you are doing this dynamically in your Java, so you'll need a dynamic SQL statment, and CFINSERT is not good for that, instead do a CFQUERY and in the SQL Where clause use multiple AND's; and but start with a condition that is always true; WHERE 1=1... This will allow you to add as many extra items as you need; or non if that happens to be the case. The 1=1 is important because without it you'll get an error if there are no extra fields to add. If you are lost, I'd suggest you pick up the book "SQL for Smarties"; SQL will help you in many future projects, and is used in all programming languages that interact with a DB. CFINSERT is just a shortcut, and is too basic for what you need...
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ColdFusion Marketplace
- database update using excell (Windows NT / 2000 / XP / 2003)
- Storing dynamic form values in Arrays for display & insert (PHP)
- insert values to mysql database (JSP)
- Please help(Problem in insertion data to database) (JSP)
- How to Hash and Store in Database (ASP.NET)
- Interface page for my new database... (MySQL)
- adding a database to my webpage (PHP)
Other Threads in the ColdFusion Forum
- Previous Thread: Developer's Opinion about CF?
- Next Thread: conditional database query


Linear Mode