Solved

insert multiple rows into database

Posted on 2010-11-16
4
279 Views
Last Modified: 2013-11-18
I am adding multiple rows to a table dynamically using jquery. I am creating the IDs also dynamically based on the values selected.

I need to insert these multiple rows into the database using coldfusion. I am stuck as to how to pass the dynamic data from the CFM to the CFC

Please help.
0
Comment
Question by:sshivanna
4 Comments
 
LVL 15

Expert Comment

by:myselfrandhawa
Comment Utility
can u show me some code what exactly are you trying to do!

which database you are using also!

you can always use the cfloop statement an dwrap the query inside to loop around the form values, but it depends which database you are using! If you can show some that will help a lot in debugging your information
0
 
LVL 2

Accepted Solution

by:
sshivanna earned 0 total points
Comment Utility
Thank you for responding. I was able to figure out a solution for this problem. My basic challenge was, that the data is dynamic. I was able to commit multiple rows to the database with a combination of jQuery and Coldfusion.

The coldfusion CFC code is very simple. All I do is a basic insert by taking the parameters as arguments.

Here is the jquery & javascript code where I am submitting ajax inserts in a loop.

            $("#btn_insertRoles").click(function(){
                  
                  //alert($("#roles_ssoid").val()+' '+ $("#rt1").html()+' '+$("#r1").html()+' '+$("#a1").html());

                  for(i=1;i<=$("#recCount").val();i++) {
                        $.ajax({
                            type: 'POST',
                            url: "<git:docroot/>ajax/insertGitUserRoles",
                            async: false,
                            data: {
                                ssoid : $("#roles_ssoid").val(),
                                roletype : $("#rt"+i).html(),
                                role : $("#r"+i).html(),
                                approver: $("#a"+i).html()
                            },
                            success: function(data, textStatus, xhr) {
                                    if (i==$("#recCount").val()){
                                      GIT.growl.ok(data);
                                    }
                                    //Clear the values of the form.
                            },
                            error: function(data, textStatus, xhr) {
                                GIT.growl.error(data.responseText);
                            },
                            dataType: 'text'
                        });
                  }                  

            });
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now